diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index e9db52458..132280431 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -87,7 +87,7 @@ impl Sweep for (Handle, Handle) { // Armed with those coordinates, creating the `Curve` of the output // `Edge` is straight-forward. let curve = { - let path = SurfacePath::line_from_points(points_surface); + let (path, _) = SurfacePath::line_from_points(points_surface); Curve::new(surface.clone(), path, edge_global.curve().clone()) .insert(objects) diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index 9f03f186d..9eb520bd5 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -37,6 +37,7 @@ impl CurveBuilder for PartialCurve { } fn update_as_line_from_points(&mut self, points: [impl Into>; 2]) { - self.path = Some(SurfacePath::line_from_points(points)); + let (path, _) = SurfacePath::line_from_points(points); + self.path = Some(path); } } diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 75bc79f49..1e2006ba5 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -67,7 +67,8 @@ impl ShellBuilder for PartialShell { }); let c = a + [Z, Z, edge_length]; - let surface = PartialSurface::plane_from_points([a, b, c]); + let (surface, _) = + PartialSurface::plane_from_points([a, b, c]); Partial::from_partial(surface) }) .collect::>(); diff --git a/crates/fj-kernel/src/builder/surface.rs b/crates/fj-kernel/src/builder/surface.rs index 9a5bfb66e..54f1efcdd 100644 --- a/crates/fj-kernel/src/builder/surface.rs +++ b/crates/fj-kernel/src/builder/surface.rs @@ -1,4 +1,4 @@ -use fj_math::{Point, Vector}; +use fj_math::{Point, Scalar, Vector}; use crate::{ geometry::{path::GlobalPath, surface::SurfaceGeometry}, @@ -6,12 +6,14 @@ use crate::{ }; /// Builder API for [`PartialSurface`] -pub trait SurfaceBuilder { +pub trait SurfaceBuilder: Sized { /// Build a surface from its two axes fn from_axes(u: GlobalPath, v: impl Into>) -> Self; /// Construct a plane from 3 points - fn plane_from_points(points: [impl Into>; 3]) -> Self; + fn plane_from_points( + points: [impl Into>; 3], + ) -> (Self, [Point<2>; 3]); } impl SurfaceBuilder for PartialSurface { @@ -23,14 +25,25 @@ impl SurfaceBuilder for PartialSurface { } } - fn plane_from_points(points: [impl Into>; 3]) -> Self { + fn plane_from_points( + points: [impl Into>; 3], + ) -> (Self, [Point<2>; 3]) { let [a, b, c] = points.map(Into::into); - let u = GlobalPath::line_from_points([a, b]); + let (u, u_coords) = GlobalPath::line_from_points([a, b]); let v = c - a; - Self { - geometry: Some(SurfaceGeometry { u, v }), - } + let coords = { + let [a, b] = u_coords.map(|point| point.t); + [[a, Scalar::ZERO], [b, Scalar::ZERO], [a, Scalar::ONE]] + .map(Point::from) + }; + + ( + Self { + geometry: Some(SurfaceGeometry { u, v }), + }, + coords, + ) } } diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index 4bce78030..d1cc59980 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -43,9 +43,13 @@ impl SurfacePath { } /// Construct a line from two points - pub fn line_from_points(points: [impl Into>; 2]) -> Self { - let (line, _) = Line::from_points(points); - Self::Line(line) + /// + /// Also returns the coordinates of the points on the path. + pub fn line_from_points( + points: [impl Into>; 2], + ) -> (Self, [Point<1>; 2]) { + let (line, coords) = Line::from_points(points); + (Self::Line(line), coords) } /// Convert a point on the path into surface coordinates @@ -103,9 +107,13 @@ impl GlobalPath { } /// Construct a line from two points - pub fn line_from_points(points: [impl Into>; 2]) -> Self { - let (line, _) = Line::from_points(points); - Self::Line(line) + /// + /// Also returns the coordinates of the points on the path. + pub fn line_from_points( + points: [impl Into>; 2], + ) -> (Self, [Point<1>; 2]) { + let (line, coords) = Line::from_points(points); + (Self::Line(line), coords) } /// Access the origin of the path's coordinate system