2034908d41 2012-05-20 kinaba: typedef long double LD; 2034908d41 2012-05-20 kinaba: typedef complex<LD> CMP; 2034908d41 2012-05-20 kinaba: 2034908d41 2012-05-20 kinaba: bool line_circle(CMP la, CMP lb, CMP c, LD r, CMP* p1, CMP* p2) 2034908d41 2012-05-20 kinaba: { 2034908d41 2012-05-20 kinaba: CMP v = (lb-la) / abs(lb-la); 2034908d41 2012-05-20 kinaba: CMP o = (c-la) / v; 2034908d41 2012-05-20 kinaba: if( abs(o.imag()) > r ) 2034908d41 2012-05-20 kinaba: return false; 2034908d41 2012-05-20 kinaba: LD dx = sqrt(r*r - o.imag()*o.imag()); 2034908d41 2012-05-20 kinaba: *p1 = la + (o.real()-dx)*v; 2034908d41 2012-05-20 kinaba: *p2 = la + (o.real()+dx)*v; 2034908d41 2012-05-20 kinaba: return true; 2034908d41 2012-05-20 kinaba: }