MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / tangent

Function tangent

code/geometry/circles.cpp:18–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 r1 = H + v, r2 = H - v;
17 return 1 + (abs(v) > EPS); }
18int tangent(P(A), C(O, r), point &r1, point &r2) {
19 point v = O - A; double d = abs(v);
20 if (d < r - EPS) return 0;
21 double alpha = asin(r / d), L = sqrt(d*d - r*r);
22 v = normalize(v, L);
23 r1 = A + rotate(v, alpha), r2 = A + rotate(v, -alpha);
24 return 1 + (abs(v) > EPS); }
25void tangent_outer(C(A,rA), C(B,rB), PP(P), PP(Q)) {
26 // if (rA - rB > EPS) { swap(rA, rB); swap(A, B); }
27 double theta = asin((rB - rA)/abs(A - B));

Callers 2

testFunction · 0.85
tangent_innerFunction · 0.85

Calls 3

sqrtFunction · 0.85
normalizeFunction · 0.85
rotateFunction · 0.85

Tested by 1

testFunction · 0.68