src/geo2d/ins/cc/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../rel/cc/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | // intersection point of two circles | ||
| 8 | //! need to check whether two circles are the same | ||
| 9 | // maybe duplicate | ||
| 10 | template <class FP> | ||
| 11 | 9464187 | CEXP auto ins_CC(circle<FP> CR c1, circle<FP> CR c2) NE { | |
| 12 |
5/6✓ Branch 1 taken 667576 times.
✓ Branch 2 taken 8796611 times.
✓ Branch 4 taken 197438 times.
✓ Branch 5 taken 470138 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 197438 times.
|
9464187 | assert(!is_eq(c1.o.x, c2.o.x) || !is_eq(c1.o.y, c2.o.y) || !is_eq(c1.r, c2.r)); |
| 13 | 9464187 | std::optional<ptt<point<FP>>> ret; | |
| 14 |
4/4✓ Branch 1 taken 4114945 times.
✓ Branch 2 taken 5349242 times.
✓ Branch 3 taken 1311440 times.
✓ Branch 4 taken 2803505 times.
|
9464187 | if (auto state = relation_CC(c1, c2); state == RELCC::lyingin || state == RELCC::lyingout) return ret; |
| 15 | 2803505 | const FP d = min(dist_PP(c1.o, c2.o), c1.r + c2.r), | |
| 16 | 2803505 | y = (c1.r * c1.r - c2.r * c2.r + d * d) / (2 * d), | |
| 17 | 2803505 | x = std::sqrt(c1.r * c1.r - y * y); | |
| 18 | 2803505 | const point dr = (c2.o - c1.o).do_unit(), q1 = c1.o + dr * y, q2 = rot90(dr) * x; | |
| 19 | 2803505 | ret.emplace(q1 - q2, q1 + q2); | |
| 20 | 2803505 | return ret; | |
| 21 | } | ||
| 22 | |||
| 23 | } // namespace tifa_libs | ||
| 24 |