Artifact a5ea821173c9c75552f74d647e264fbbcfcb29cd
- File
lib/geo/area.cpp
- 2013-06-30 08:35:05 - part of checkin [07ad2e1283] on branch trunk - Geocon library update. (user: kinaba) [annotate]
//------------------------------------------------------------- // 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; }