Artifact Content
Not logged in

Artifact a5ea821173c9c75552f74d647e264fbbcfcb29cd


//-------------------------------------------------------------
// Area of a polygon
//   O(N)
//
// Verified by
//   - SRM 337 Div1 LV3
//   - SRM 486 Div1 LV3
//-------------------------------------------------------------

double outer_prod(const CMP& a, const CMP& b) { return imag(conj(a)*b); }

double area( const vector<pt>& q )
{
	double a = 0.0;

	pt o = q[0];
	for(int i=1; i+1<q.size(); ++i)
		a += outer_prod(q[i]-o, q[i+1]-o);
	return abs(a) / 2;
}