MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / circle_circle_relation

Function circle_circle_relation

Geometry/Geometry 2D.cpp:332–341  ·  view source on GitHub ↗

5 - outside and do not intersect 4 - intersect outside in one point 3 - intersect in 2 points 2 - intersect inside in one point 1 - inside and do not intersect

Source from the content-addressed store, hash-verified

330//2 - intersect inside in one point
331//1 - inside and do not intersect
332int circle_circle_relation(PT a, double r, PT b, double R) {
333 double d = dist(a, b);
334 if (sign(d - r - R) > 0) return 5;
335 if (sign(d - r - R) == 0) return 4;
336 double l = fabs(r - R);
337 if (sign(d - r - R) < 0 && sign(d - l) > 0) return 3;
338 if (sign(d - l) == 0) return 2;
339 if (sign(d - l) < 0) return 1;
340 assert(0); return -1;
341}
342vector<PT> circle_circle_intersection(PT a, double r, PT b, double R) {
343 if (a == b && sign(r - R) == 0) return {PT(1e18, 1e18)};
344 vector<PT> ret;

Callers

nothing calls this directly

Calls 2

distFunction · 0.70
signFunction · 0.70

Tested by

no test coverage detected