From a67200c5c7a2264160c9174469c42db69a9ad16a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 6 May 2022 17:26:23 +0200 Subject: [PATCH 1/4] Add more `Curve` constructors --- crates/fj-kernel/src/geometry/curves/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/fj-kernel/src/geometry/curves/mod.rs b/crates/fj-kernel/src/geometry/curves/mod.rs index cee793cb8..0bb26324c 100644 --- a/crates/fj-kernel/src/geometry/curves/mod.rs +++ b/crates/fj-kernel/src/geometry/curves/mod.rs @@ -32,6 +32,22 @@ impl Curve { }) } + /// Construct a `Curve` that represents the y-axis + pub fn y_axis() -> Self { + Self::Line(Line { + origin: Point::origin(), + direction: Vector::unit_y(), + }) + } + + /// Construct a `Curve` that represents the z-axis + pub fn z_axis() -> Self { + Self::Line(Line { + origin: Point::origin(), + direction: Vector::unit_z(), + }) + } + /// Access the origin of the curve's coordinate system pub fn origin(&self) -> Point<3> { match self { From 50c069ebafe00b5de68e420576358790e8b11cab Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 6 May 2022 17:26:43 +0200 Subject: [PATCH 2/4] Change wording in doc comment Make it more consistent with how axes are called in the `Curve` documentation. --- crates/fj-kernel/src/geometry/surfaces/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/geometry/surfaces/mod.rs b/crates/fj-kernel/src/geometry/surfaces/mod.rs index 37619b20a..c00610448 100644 --- a/crates/fj-kernel/src/geometry/surfaces/mod.rs +++ b/crates/fj-kernel/src/geometry/surfaces/mod.rs @@ -16,7 +16,7 @@ pub enum Surface { } impl Surface { - /// Construct a `Surface` that represents the x-y plane + /// Construct a `Surface` that represents the xy-plane pub fn x_y_plane() -> Self { Self::SweptCurve(SweptCurve { curve: Curve::x_axis(), From 06aba87c3873ceeaf0d00ade861a85f9a8541a16 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 6 May 2022 17:49:46 +0200 Subject: [PATCH 3/4] Update method name The new name follows the wording used in the documentation. --- crates/fj-kernel/src/algorithms/approx/faces.rs | 2 +- crates/fj-kernel/src/algorithms/triangulation/mod.rs | 4 ++-- .../src/algorithms/triangulation/polygon.rs | 12 ++++++------ crates/fj-kernel/src/geometry/surfaces/mod.rs | 2 +- crates/fj-kernel/src/shape/api.rs | 4 ++-- crates/fj-operations/src/circle.rs | 2 +- crates/fj-operations/src/sketch.rs | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/faces.rs b/crates/fj-kernel/src/algorithms/approx/faces.rs index 0171214ae..09346e893 100644 --- a/crates/fj-kernel/src/algorithms/approx/faces.rs +++ b/crates/fj-kernel/src/algorithms/approx/faces.rs @@ -105,7 +105,7 @@ mod tests { let g = Point::from([2., 2., 0.]); let h = Point::from([1., 2., 0.]); - let face = Face::builder(Surface::x_y_plane(), &mut shape) + let face = Face::builder(Surface::xy_plane(), &mut shape) .with_exterior_polygon([a, b, c, d]) .with_interior_polygon([e, f, g, h]) .build()?; diff --git a/crates/fj-kernel/src/algorithms/triangulation/mod.rs b/crates/fj-kernel/src/algorithms/triangulation/mod.rs index 8d5643c5d..aa207dc99 100644 --- a/crates/fj-kernel/src/algorithms/triangulation/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulation/mod.rs @@ -96,7 +96,7 @@ mod tests { let c = [2., 2., 0.]; let d = [0., 1., 0.]; - Face::builder(Surface::x_y_plane(), &mut shape) + Face::builder(Surface::xy_plane(), &mut shape) .with_exterior_polygon([a, b, c, d]) .build()?; @@ -123,7 +123,7 @@ mod tests { let g = [3., 3., 0.]; let h = [1., 2., 0.]; - Face::builder(Surface::x_y_plane(), &mut shape) + Face::builder(Surface::xy_plane(), &mut shape) .with_exterior_polygon([a, b, c, d]) .with_interior_polygon([e, f, g, h]) .build()?; diff --git a/crates/fj-kernel/src/algorithms/triangulation/polygon.rs b/crates/fj-kernel/src/algorithms/triangulation/polygon.rs index aeb9e251c..5ab3f37d3 100644 --- a/crates/fj-kernel/src/algorithms/triangulation/polygon.rs +++ b/crates/fj-kernel/src/algorithms/triangulation/polygon.rs @@ -235,7 +235,7 @@ mod tests { let e = [2., 1.]; let f = [1., 2.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c]).close()) .with_interiors([PolyChain::from([d, e, f]).close()]); @@ -248,7 +248,7 @@ mod tests { let b = [2., 1.]; let c = [0., 2.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c]).close()); assert_contains_point(polygon, [1., 1.]); @@ -264,7 +264,7 @@ mod tests { let e = [2., 1.]; let f = [1., 3.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c]).close()) .with_interiors([PolyChain::from([d, e, f]).close()]); @@ -278,7 +278,7 @@ mod tests { let c = [3., 0.]; let d = [3., 4.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c, d]).close()); assert_contains_point(polygon, [1., 1.]); @@ -291,7 +291,7 @@ mod tests { let b = [2., 1.]; let c = [3., 1.]; let d = [0., 2.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c, d]).close()); assert_contains_point(polygon, [1., 1.]); @@ -301,7 +301,7 @@ mod tests { let c = [3., 1.]; let d = [4., 0.]; let e = [4., 5.]; - let polygon = Polygon::new(Surface::x_y_plane()) + let polygon = Polygon::new(Surface::xy_plane()) .with_exterior(PolyChain::from([a, b, c, d, e]).close()); assert_contains_point(polygon, [1., 1.]); } diff --git a/crates/fj-kernel/src/geometry/surfaces/mod.rs b/crates/fj-kernel/src/geometry/surfaces/mod.rs index c00610448..a97972e63 100644 --- a/crates/fj-kernel/src/geometry/surfaces/mod.rs +++ b/crates/fj-kernel/src/geometry/surfaces/mod.rs @@ -17,7 +17,7 @@ pub enum Surface { impl Surface { /// Construct a `Surface` that represents the xy-plane - pub fn x_y_plane() -> Self { + pub fn xy_plane() -> Self { Self::SweptCurve(SweptCurve { curve: Curve::x_axis(), path: Vector::unit_y(), diff --git a/crates/fj-kernel/src/shape/api.rs b/crates/fj-kernel/src/shape/api.rs index dc23c5d9b..4c3e9e7e3 100644 --- a/crates/fj-kernel/src/shape/api.rs +++ b/crates/fj-kernel/src/shape/api.rs @@ -214,7 +214,7 @@ mod tests { let point = Point::from([1., 0., 0.]); let curve = Curve::x_axis(); - let surface = Surface::x_y_plane(); + let surface = Surface::xy_plane(); assert!(shape.get_handle(&point).is_none()); assert!(shape.get_handle(&curve).is_none()); @@ -396,7 +396,7 @@ mod tests { } fn add_surface(&mut self) -> Handle { - self.insert(Surface::x_y_plane()).unwrap() + self.insert(Surface::xy_plane()).unwrap() } fn add_edge(&mut self) -> anyhow::Result> { diff --git a/crates/fj-operations/src/circle.rs b/crates/fj-operations/src/circle.rs index b10557ead..a0dcff129 100644 --- a/crates/fj-operations/src/circle.rs +++ b/crates/fj-operations/src/circle.rs @@ -22,7 +22,7 @@ impl ToShape for fj::Circle { shape.insert(Cycle { edges: vec![edge] }).unwrap(); let cycles = shape.cycles().collect(); - let surface = shape.insert(Surface::x_y_plane()).unwrap(); + let surface = shape.insert(Surface::xy_plane()).unwrap(); shape .insert(Face::Face { exteriors: cycles, diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index a2ec6b2b4..bafd17c9a 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -46,7 +46,7 @@ impl ToShape for fj::Sketch { shape.insert(Cycle { edges }).unwrap(); }; - let surface = shape.insert(Surface::x_y_plane()).unwrap(); + let surface = shape.insert(Surface::xy_plane()).unwrap(); let face = Face::Face { exteriors: shape.cycles().collect(), interiors: Vec::new(), From ed3404a3c4af7512363904d33a7d55456f4a619c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 6 May 2022 17:27:14 +0200 Subject: [PATCH 4/4] Add more `Surface` constructors --- crates/fj-kernel/src/geometry/surfaces/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/fj-kernel/src/geometry/surfaces/mod.rs b/crates/fj-kernel/src/geometry/surfaces/mod.rs index a97972e63..0c88f1adc 100644 --- a/crates/fj-kernel/src/geometry/surfaces/mod.rs +++ b/crates/fj-kernel/src/geometry/surfaces/mod.rs @@ -24,6 +24,22 @@ impl Surface { }) } + /// Construct a `Surface` that represents the xz-plane + pub fn xz_plane() -> Self { + Self::SweptCurve(SweptCurve { + curve: Curve::x_axis(), + path: Vector::unit_z(), + }) + } + + /// Construct a `Surface` that represents the yz-plane + pub fn yz_plane() -> Self { + Self::SweptCurve(SweptCurve { + curve: Curve::y_axis(), + path: Vector::unit_z(), + }) + } + /// Create a new instance that is reversed #[must_use] pub fn reverse(self) -> Self {