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/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 { diff --git a/crates/fj-kernel/src/geometry/surfaces/mod.rs b/crates/fj-kernel/src/geometry/surfaces/mod.rs index 37619b20a..0c88f1adc 100644 --- a/crates/fj-kernel/src/geometry/surfaces/mod.rs +++ b/crates/fj-kernel/src/geometry/surfaces/mod.rs @@ -16,14 +16,30 @@ pub enum Surface { } impl Surface { - /// Construct a `Surface` that represents the x-y plane - pub fn x_y_plane() -> Self { + /// Construct a `Surface` that represents the xy-plane + pub fn xy_plane() -> Self { Self::SweptCurve(SweptCurve { curve: Curve::x_axis(), path: Vector::unit_y(), }) } + /// 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 { 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(),