Artifact 0f1f35288c2dfafe8dc2a60c44c65fb22fa3de26
- File
lib/geo/line_circle.cpp
- 2012-05-20 14:16:51 - part of checkin [2034908d41] on branch trunk - 543 (user: kinaba) [annotate]
typedef long double LD; typedef complex<LD> CMP; bool line_circle(CMP la, CMP lb, CMP c, LD r, CMP* p1, CMP* p2) { CMP v = (lb-la) / abs(lb-la); CMP o = (c-la) / v; if( abs(o.imag()) > r ) return false; LD dx = sqrt(r*r - o.imag()*o.imag()); *p1 = la + (o.real()-dx)*v; *p2 = la + (o.real()+dx)*v; return true; }