pub fn convex_polygons_intersection_points(
poly1: &[Point2<f32>],
poly2: &[Point2<f32>],
out: &mut Vec<Point2<f32>>,
)Expand description
Computes the intersection points of two convex polygons.
This function takes two convex polygons and computes their intersection, returning
the vertices of the resulting intersection polygon. The result is added to the out vector.
§Important Notes
- Convex polygons only: Both input polygons must be convex. For non-convex polygons,
use
polygons_intersection_pointsinstead. - Counter-clockwise winding: Input polygons should be oriented counter-clockwise.
- Default tolerances: Uses default numerical tolerances. For custom tolerances,
use
convex_polygons_intersection_points_with_tolerances.
§Arguments
poly1- First convex polygon as a slice of verticespoly2- Second convex polygon as a slice of verticesout- Output vector where intersection vertices will be appended
§Examples
// Define two overlapping squares
let square1 = vec![
Point2::origin(),
Point2::new(2.0, 0.0),
Point2::new(2.0, 2.0),
Point2::new(0.0, 2.0),
];
let square2 = vec![
Point2::new(1.0, 1.0),
Point2::new(3.0, 1.0),
Point2::new(3.0, 3.0),
Point2::new(1.0, 3.0),
];
let mut intersection = Vec::new();
convex_polygons_intersection_points(&square1, &square2, &mut intersection);
// The intersection should be a square from (1,1) to (2,2)
assert_eq!(intersection.len(), 4);§See Also
convex_polygons_intersection- For closure-based outputpolygons_intersection_points- For non-convex polygons