Differences From Artifact [05f672d15009c4b5]:
- File
_lib/geo/pt_in_poly.cpp
- 2011-02-23 09:21:16 - part of checkin [4fd800b3a8] on branch trunk - Copied from private svn repository. (user: kinaba) [annotate]
- File
lib/geo/pt_in_poly.cpp
- 2011-02-23 11:18:09 - part of checkin [23dfcca431] on branch trunk - renamed _lib to lib (user: kinaba) [annotate]
To Artifact [f28d7402b7cb4529]:
- File
lib/geo/pt_in_poly.cpp
- 2013-06-30 08:35:05 - part of checkin [07ad2e1283] on branch trunk - Geocon library update. (user: kinaba) [annotate]
2 //------------------------------------------------------------- 2 //-------------------------------------------------------------
3 // The circle passing three points 3 // The circle passing three points
4 // 4 //
5 // Verified by 5 // Verified by
6 // - AOJ 0012 (only triangles) 6 // - AOJ 0012 (only triangles)
7 //------------------------------------------------------------- 7 //-------------------------------------------------------------
8 8
9 double outer_prod( CMP a, CMP b ) | 9 double outer_prod(const CMP& a, const CMP& b) { return imag(conj(a)*b); }
10 { <
11 return (a.real()*b.imag() - b.real()*a.imag())/2; <
12 } <
13 10
14 bool point_in_polygon( vector<CMP>& ps, CMP p ) 11 bool point_in_polygon( vector<CMP>& ps, CMP p )
15 { 12 {
16 bool in = false; 13 bool in = false;
17 for(int i=0; i<ps.size(); ++i) { 14 for(int i=0; i<ps.size(); ++i) {
18 CMP a = ps[i] - p; 15 CMP a = ps[i] - p;
19 CMP b = ps[(i+1)%ps.size()] - p; 16 CMP b = ps[(i+1)%ps.size()] - p;