Function cavalier_contours::core::math::circle_circle_intr
source · pub fn circle_circle_intr<T>(
radius1: T,
center1: Vector2<T>,
radius2: T,
center2: Vector2<T>,
epsilon: T
) -> CircleCircleIntr<T>where
T: Real,
Expand description
Finds the intersects between two circles defined by the radius and center.
This function returns the geometric solution(s) for the intersection of two circles.
The result will hold NoIntersect
, if the circles are too far apart, Overlapping
if the circles are similar in radii and center. In the other cases, the result will
hold either a TangentIntersect
with a single intersection point or TwoIntersects
with two intersection points.
epsilon
is used for fuzzy float comparisons.
Examples
// Two tangent-intersecting circles of radius `1.0` with euclidean distance of `2.0`
let r1 = 1.0;
let c1 = Vector2::new(0.0, 0.0);
let r2 = 1.0;
let c2 = Vector2::new(0.0, 2.0);
if let CircleCircleIntr::TangentIntersect { point: p } =
circle_circle_intr(r1, c1, r2, c2, 1e-5)
{
assert_eq!(p, Vector2::new(0.0, 1.0));
} else {
unreachable!("expected a tangent intersection");
}