From d94e1122336da84d53512e3e4bdbbda7cdc31cce Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:14:00 +0100 Subject: [PATCH 1/6] Fix word in comment --- crates/fj-kernel/src/geometry/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index 666628254..05fc27cf1 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -47,7 +47,7 @@ impl SurfacePath { Self::Line(Line::from_points(points)) } - /// Convert a point on the path into global coordinates + /// Convert a point on the path into surface coordinates pub fn point_from_path_coords( &self, point: impl Into>, From a77c13ba160d5a64de9673e9ff9ce0bc65641e53 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:13:50 +0100 Subject: [PATCH 2/6] Refactor --- crates/fj-kernel/src/geometry/path.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index 05fc27cf1..364081526 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -44,7 +44,8 @@ impl SurfacePath { /// Construct a line from two points pub fn line_from_points(points: [impl Into>; 2]) -> Self { - Self::Line(Line::from_points(points)) + let line = Line::from_points(points); + Self::Line(line) } /// Convert a point on the path into surface coordinates @@ -103,7 +104,8 @@ impl GlobalPath { /// Construct a line from two points pub fn line_from_points(points: [impl Into>; 2]) -> Self { - Self::Line(Line::from_points(points)) + let line = Line::from_points(points); + Self::Line(line) } /// Access the origin of the path's coordinate system From 07c3eda2d703507f7445928d2be3ceeacba96dc1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:17:55 +0100 Subject: [PATCH 3/6] Refactor --- crates/fj-kernel/src/builder/surface.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/builder/surface.rs b/crates/fj-kernel/src/builder/surface.rs index cc1d57728..9a5bfb66e 100644 --- a/crates/fj-kernel/src/builder/surface.rs +++ b/crates/fj-kernel/src/builder/surface.rs @@ -1,4 +1,4 @@ -use fj_math::{Line, Point, Vector}; +use fj_math::{Point, Vector}; use crate::{ geometry::{path::GlobalPath, surface::SurfaceGeometry}, @@ -26,7 +26,7 @@ impl SurfaceBuilder for PartialSurface { fn plane_from_points(points: [impl Into>; 3]) -> Self { let [a, b, c] = points.map(Into::into); - let u = GlobalPath::Line(Line::from_points([a, b])); + let u = GlobalPath::line_from_points([a, b]); let v = c - a; Self { From f5c61753cbcf50a6f7e6ce9b08aa26f640fb5924 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:21:04 +0100 Subject: [PATCH 4/6] Refactor --- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index a5df93842..e9db52458 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -1,4 +1,4 @@ -use fj_math::{Line, Point, Scalar, Vector}; +use fj_math::{Point, Scalar, Vector}; use crate::{ geometry::path::SurfacePath, @@ -87,14 +87,10 @@ impl Sweep for (Handle, Handle) { // Armed with those coordinates, creating the `Curve` of the output // `Edge` is straight-forward. let curve = { - let line = Line::from_points(points_surface); + let path = SurfacePath::line_from_points(points_surface); - Curve::new( - surface.clone(), - SurfacePath::Line(line), - edge_global.curve().clone(), - ) - .insert(objects) + Curve::new(surface.clone(), path, edge_global.curve().clone()) + .insert(objects) }; let vertices_surface = { From 8942f2ee2973dc87b1f2b92a0d7954fca8c7eead Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:19:13 +0100 Subject: [PATCH 5/6] Return line coordinates from `Line::from_points` --- crates/fj-kernel/src/geometry/path.rs | 4 ++-- crates/fj-math/src/line.rs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index 364081526..4bce78030 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -44,7 +44,7 @@ impl SurfacePath { /// Construct a line from two points pub fn line_from_points(points: [impl Into>; 2]) -> Self { - let line = Line::from_points(points); + let (line, _) = Line::from_points(points); Self::Line(line) } @@ -104,7 +104,7 @@ impl GlobalPath { /// Construct a line from two points pub fn line_from_points(points: [impl Into>; 2]) -> Self { - let line = Line::from_points(points); + let (line, _) = Line::from_points(points); Self::Line(line) } diff --git a/crates/fj-math/src/line.rs b/crates/fj-math/src/line.rs index bec71a29c..cd56ff250 100644 --- a/crates/fj-math/src/line.rs +++ b/crates/fj-math/src/line.rs @@ -34,10 +34,15 @@ impl Line { /// # Panics /// /// Panics, if the points are coincident. - pub fn from_points(points: [impl Into>; 2]) -> Self { + pub fn from_points( + points: [impl Into>; 2], + ) -> (Self, [Point<1>; 2]) { let [a, b] = points.map(Into::into); - Self::from_origin_and_direction(a, b - a) + let line = Self::from_origin_and_direction(a, b - a); + let coords = [[0.], [1.]].map(Point::from); + + (line, coords) } /// Create a line from two points that include line coordinates @@ -175,11 +180,11 @@ mod tests { #[test] fn is_coincident_with() { - let line = Line::from_points([[0., 0.], [1., 0.]]); + let (line, _) = Line::from_points([[0., 0.], [1., 0.]]); - let a = Line::from_points([[0., 0.], [1., 0.]]); - let b = Line::from_points([[0., 0.], [-1., 0.]]); - let c = Line::from_points([[0., 1.], [1., 1.]]); + let (a, _) = Line::from_points([[0., 0.], [1., 0.]]); + let (b, _) = Line::from_points([[0., 0.], [-1., 0.]]); + let (c, _) = Line::from_points([[0., 1.], [1., 1.]]); assert!(line.is_coincident_with(&a)); assert!(line.is_coincident_with(&b)); From 5dc567eac3bb0e02cfa6b931279b4be3f8f0c5a6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Dec 2022 16:19:46 +0100 Subject: [PATCH 6/6] Update doc comment --- crates/fj-math/src/line.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/fj-math/src/line.rs b/crates/fj-math/src/line.rs index cd56ff250..900006f58 100644 --- a/crates/fj-math/src/line.rs +++ b/crates/fj-math/src/line.rs @@ -31,6 +31,9 @@ impl Line { /// Create a line from two points /// + /// Also returns the lines coordinates of the provided points on the new + /// line. + /// /// # Panics /// /// Panics, if the points are coincident.