Artifact bec880bc3280bac95260f0971c9a970b73fb46f8:
0000: 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d //--------------
0010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a ---------------.
0040: 2f 2f 20 63 63 77 0a 2f 2f 0a 2f 2f 20 56 65 72 // ccw.//.// Ver
0050: 69 66 69 65 64 20 62 79 0a 2f 2f 20 20 20 2d 20 ified by.// -
0060: 53 52 4d 20 34 39 32 20 44 69 76 31 20 4c 56 31 SRM 492 Div1 LV1
0070: 0a 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d .//-------------
0080: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0090: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
00a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
00b0: 0a 0a 64 6f 75 62 6c 65 20 6f 75 74 65 72 5f 70 ..double outer_p
00c0: 72 6f 64 28 63 6f 6e 73 74 20 43 4d 50 26 20 61 rod(const CMP& a
00d0: 2c 20 63 6f 6e 73 74 20 43 4d 50 26 20 62 29 20 , const CMP& b)
00e0: 7b 20 72 65 74 75 72 6e 20 69 6d 61 67 28 63 6f { return imag(co
00f0: 6e 6a 28 61 29 2a 62 29 3b 20 7d 0a 64 6f 75 62 nj(a)*b); }.doub
0100: 6c 65 20 69 6e 6e 65 72 5f 70 72 6f 64 28 63 6f le inner_prod(co
0110: 6e 73 74 20 43 4d 50 26 20 61 2c 20 63 6f 6e 73 nst CMP& a, cons
0120: 74 20 43 4d 50 26 20 62 29 20 7b 20 72 65 74 75 t CMP& b) { retu
0130: 72 6e 20 72 65 61 6c 28 63 6f 6e 6a 28 61 29 2a rn real(conj(a)*
0140: 62 29 3b 20 7d 0a 0a 69 6e 74 20 63 63 77 28 63 b); }..int ccw(c
0150: 6f 6e 73 74 20 43 4d 50 26 20 61 2c 20 43 4d 50 onst CMP& a, CMP
0160: 20 62 2c 20 43 4d 50 20 63 29 20 7b 0a 09 62 20 b, CMP c) {..b
0170: 2d 3d 20 61 3b 20 63 20 2d 3d 20 61 3b 0a 09 69 -= a; c -= a;..i
0180: 66 28 20 6f 75 74 65 72 5f 70 72 6f 64 28 62 2c f( outer_prod(b,
0190: 63 29 20 3e 20 30 20 29 20 72 65 74 75 72 6e 20 c) > 0 ) return
01a0: 2b 31 3b 20 2f 2f 20 63 6f 75 6e 74 65 72 20 63 +1; // counter c
01b0: 6c 6f 63 6b 77 69 73 65 0a 09 69 66 28 20 6f 75 lockwise..if( ou
01c0: 74 65 72 5f 70 72 6f 64 28 62 2c 63 29 20 3c 20 ter_prod(b,c) <
01d0: 30 20 29 20 72 65 74 75 72 6e 20 2d 31 3b 20 2f 0 ) return -1; /
01e0: 2f 20 63 6c 6f 63 6b 77 69 73 65 0a 09 69 66 28 / clockwise..if(
01f0: 20 69 6e 6e 65 72 5f 70 72 6f 64 28 62 2c 63 29 inner_prod(b,c)
0200: 20 3c 20 30 20 29 20 72 65 74 75 72 6e 20 2b 32 < 0 ) return +2
0210: 3b 20 2f 2f 20 63 2d 2d 5b 61 2d 2d 62 5d 20 6f ; // c--[a--b] o
0220: 6e 20 6c 69 6e 65 0a 09 69 66 28 20 6e 6f 72 6d n line..if( norm
0230: 28 62 29 20 3c 20 6e 6f 72 6d 28 63 29 20 29 20 (b) < norm(c) )
0240: 20 20 72 65 74 75 72 6e 20 2d 32 3b 20 2f 2f 20 return -2; //
0250: 5b 61 2d 2d 62 5d 2d 2d 63 20 6f 6e 20 6c 69 6e [a--b]--c on lin
0260: 65 0a 09 72 65 74 75 72 6e 20 30 3b 20 2f 2f 20 e..return 0; //
0270: 5b 61 2d 2d 63 2d 2d 62 5d 20 6f 6e 20 6c 69 6e [a--c--b] on lin
0280: 65 0a 7d 0a 0a 0a 2f 2f 20 69 6e 74 65 72 73 65 e.}...// interse
0290: 63 74 69 6f 6e 20 6f 66 20 74 77 6f 20 6c 69 6e ction of two lin
02a0: 65 20 73 65 67 6d 65 6e 74 73 2e 0a 62 6f 6f 6c e segments..bool
02b0: 20 63 72 6f 73 73 28 43 4d 50 20 70 31 2c 20 43 cross(CMP p1, C
02c0: 4d 50 20 70 32 2c 20 43 4d 50 20 50 31 2c 20 43 MP p2, CMP P1, C
02d0: 4d 50 20 50 32 29 20 7b 0a 09 72 65 74 75 72 6e MP P2) {..return
02e0: 20 63 63 77 28 70 31 2c 70 32 2c 50 31 29 2a 63 ccw(p1,p2,P1)*c
02f0: 63 77 28 70 31 2c 70 32 2c 50 32 29 3c 3d 30 20 cw(p1,p2,P2)<=0
0300: 26 26 20 63 63 77 28 50 31 2c 50 32 2c 70 31 29 && ccw(P1,P2,p1)
0310: 2a 63 63 77 28 50 31 2c 50 32 2c 70 32 29 3c 3d *ccw(P1,P2,p2)<=
0320: 30 3b 0a 7d 0a 0;.}.