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

Function tangent_outer

code/geometry/circles.cpp:25–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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));
28 point v = rotate(B - A, theta + pi/2),
29 u = rotate(B - A, -(theta + pi/2));
30 u = normalize(u, rA);
31 P.first = A + normalize(v, rA);
32 P.second = B + normalize(v, rB);
33 Q.first = A + normalize(u, rA);
34 Q.second = B + normalize(u, rB); }
35void tangent_inner(C(A,rA), C(B,rB), PP(P), PP(Q)) {
36 point ip = (rA*B + rB*A)/(rA+rB);
37 assert(tangent(ip, A, rA, P.first, Q.first) == 2);

Callers 1

testFunction · 0.85

Calls 2

rotateFunction · 0.85
normalizeFunction · 0.85

Tested by 1

testFunction · 0.68