diff --git a/crates/fj-core/src/geometry/curves/circle.rs b/crates/fj-core/src/geometry/curves/circle.rs index 4abf99adf..93e572b19 100644 --- a/crates/fj-core/src/geometry/curves/circle.rs +++ b/crates/fj-core/src/geometry/curves/circle.rs @@ -5,7 +5,10 @@ use std::iter; use approx::AbsDiffEq; use fj_math::{Aabb, Point, Scalar, Sign, Transform, Vector}; -use crate::geometry::{traits::GenPolyline, CurveBoundary, Tolerance}; +use crate::geometry::{ + traits::{GenPolyline, LineSegment}, + CurveBoundary, Tolerance, +}; /// An n-dimensional circle /// @@ -188,7 +191,7 @@ impl GenPolyline for Circle { &self, point: Point<1>, tolerance: Tolerance, - ) -> [Point; 2] { + ) -> LineSegment { let params = CircleApproxParams::new(self, tolerance); // The approximation parameters have an increment, in curve coordinates, @@ -211,8 +214,10 @@ impl GenPolyline for Circle { }); // And finally, convert those into points of the desired dimensionality. - points_curve - .map(|point_curve| self.point_from_circle_coords([point_curve])) + let points = points_curve + .map(|point_curve| self.point_from_circle_coords([point_curve])); + + LineSegment { points } } fn generate_polyline( diff --git a/crates/fj-core/src/geometry/curves/line.rs b/crates/fj-core/src/geometry/curves/line.rs index a88aaa6e4..ea15b4327 100644 --- a/crates/fj-core/src/geometry/curves/line.rs +++ b/crates/fj-core/src/geometry/curves/line.rs @@ -2,18 +2,23 @@ use fj_math::{Line, Point}; -use crate::geometry::{traits::GenPolyline, CurveBoundary, Tolerance}; +use crate::geometry::{ + traits::{GenPolyline, LineSegment}, + CurveBoundary, Tolerance, +}; impl GenPolyline for Line { fn origin(&self) -> Point { self.origin() } - fn line_segment_at(&self, point: Point<1>, _: Tolerance) -> [Point; 2] { + fn line_segment_at(&self, point: Point<1>, _: Tolerance) -> LineSegment { // Collapse line segment into a point, as per documentation. let point = self.origin() + self.direction() * point.t; - [point, point] + LineSegment { + points: [point, point], + } } fn generate_polyline( diff --git a/crates/fj-core/src/geometry/surface.rs b/crates/fj-core/src/geometry/surface.rs index 3c0b5d4ca..d7177d8a4 100644 --- a/crates/fj-core/src/geometry/surface.rs +++ b/crates/fj-core/src/geometry/surface.rs @@ -66,6 +66,7 @@ impl SurfaceGeom { let [a, b] = self .u .line_segment_at(Point::from([point_surface.u]), tolerance.into()) + .points .map(|point_global| point_global + self.v * point_surface.v); let c = a + (b - a) / 2.; diff --git a/crates/fj-core/src/geometry/traits.rs b/crates/fj-core/src/geometry/traits.rs index 599fbeb9c..ac4ad1000 100644 --- a/crates/fj-core/src/geometry/traits.rs +++ b/crates/fj-core/src/geometry/traits.rs @@ -48,7 +48,7 @@ pub trait GenPolyline { &self, point: Point<1>, tolerance: Tolerance, - ) -> [Point; 2]; + ) -> LineSegment; /// # Generate a polyline within the provided boundary fn generate_polyline( @@ -72,7 +72,7 @@ impl GenPolyline for Path { &self, point: Point<1>, tolerance: Tolerance, - ) -> [Point; 2] { + ) -> LineSegment { match self { Self::Circle(circle) => circle.line_segment_at(point, tolerance), Self::Line(line) => line.line_segment_at(point, tolerance),