diff --git a/crates/fj-core/src/geometry/util.rs b/crates/fj-core/src/geometry/util.rs index 35710d8cc..1bc0744df 100644 --- a/crates/fj-core/src/geometry/util.rs +++ b/crates/fj-core/src/geometry/util.rs @@ -7,9 +7,9 @@ //! module provides an easy place to put new things, before it's clear what to //! do with them long-term. -use fj_math::Point; +use fj_math::{Aabb, Point}; -use super::{traits::GenPolyline, Tolerance}; +use super::{traits::GenPolyline, CurveBoundary, Tolerance}; /// # Convert a point on a curve from curve coordinates to surface coordinates pub fn curve_point_to_surface_point( @@ -25,3 +25,20 @@ pub fn curve_point_to_surface_point( line.point_from_line_coords(point_curve) } + +/// # Generate a 2D axis-aligned bounding box for a curve in a given range +pub fn surface_aabb_from_bounded_curve( + curve: &dyn GenPolyline<2>, + boundary: impl Into>>, + tolerance: impl Into, +) -> Aabb<2> { + let boundary = boundary.into(); + let tolerance = tolerance.into(); + + let points_curve = curve.generate_polyline(boundary, tolerance); + let points_surface = points_curve.into_iter().map(|point_curve| { + curve_point_to_surface_point(curve, point_curve, tolerance) + }); + + Aabb::<2>::from_points(points_surface) +}