Artifact Content
Not logged in

Artifact 959cda21c7e42a70dc6791077e124c0aebde0573


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

double outer_prod( pt a, pt b )
{
	return (a.real()*b.imag() - b.real()*a.imag())/2;
}

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;
}