From 03a37986ceecbf46ccadea845cc2301318baba23 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 14 Feb 2022 18:02:53 +0100 Subject: [PATCH] WIP Add support for swept surfaces --- src/kernel/geometry/surfaces/mod.rs | 12 ++++++- src/kernel/geometry/surfaces/swept.rs | 47 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/kernel/geometry/surfaces/swept.rs diff --git a/src/kernel/geometry/surfaces/mod.rs b/src/kernel/geometry/surfaces/mod.rs index 8bb03a86d..b1937d691 100644 --- a/src/kernel/geometry/surfaces/mod.rs +++ b/src/kernel/geometry/surfaces/mod.rs @@ -1,6 +1,7 @@ pub mod plane; +pub mod swept; -pub use self::plane::Plane; +pub use self::{plane::Plane, swept::Swept}; use nalgebra::vector; use parry3d_f64::math::Isometry; @@ -14,6 +15,11 @@ use super::points::SurfacePoint; pub enum Surface { /// A plane Plane(Plane), + + /// A swept curve + // TASK: Un-suppress warning. + #[allow(unused)] + Swept(Swept), } impl Surface { @@ -31,6 +37,7 @@ impl Surface { pub fn transform(self, transform: &Isometry) -> Self { match self { Self::Plane(surface) => Self::Plane(surface.transform(transform)), + Self::Swept(surface) => Self::Swept(surface.transform(transform)), } } @@ -38,6 +45,7 @@ impl Surface { pub fn point_model_to_surface(&self, point_3d: Point<3>) -> SurfacePoint { let point_2d = match self { Self::Plane(surface) => surface.point_model_to_surface(point_3d), + Self::Swept(surface) => surface.point_model_to_surface(point_3d), }; SurfacePoint { @@ -50,6 +58,7 @@ impl Surface { pub fn point_surface_to_model(&self, point: &Point<2>) -> Point<3> { match self { Self::Plane(surface) => surface.point_surface_to_model(point), + Self::Swept(surface) => surface.point_surface_to_model(point), } } @@ -57,6 +66,7 @@ impl Surface { pub fn vector_surface_to_model(&self, vector: &Vector<2>) -> Vector<3> { match self { Self::Plane(surface) => surface.vector_surface_to_model(vector), + Self::Swept(surface) => surface.vector_surface_to_model(vector), } } } diff --git a/src/kernel/geometry/surfaces/swept.rs b/src/kernel/geometry/surfaces/swept.rs new file mode 100644 index 000000000..5472eb124 --- /dev/null +++ b/src/kernel/geometry/surfaces/swept.rs @@ -0,0 +1,47 @@ +use parry3d_f64::math::Isometry; + +use crate::{ + kernel::geometry::Curve, + math::{Point, Vector}, +}; + +/// A surface that was swept from a curve +#[derive(Clone, Debug, PartialEq)] +pub struct Swept { + /// The curve that this surface was swept from + pub curve: Curve, + + /// The path that the curve was swept along + /// + /// Currently, only sweeps along the z-axis are supported. + pub path: Vector<1>, +} + +impl Swept { + /// Transform the surface + #[must_use] + pub fn transform(self, _transform: &Isometry) -> Self { + // TASK: Implement. + todo!() + } + + /// Convert a point in model coordinates to surface coordinates + pub fn point_model_to_surface(&self, _point: Point<3>) -> Point<2> { + // TASK: Implement. + todo!() + } + + /// Convert a point in surface coordinates to model coordinates + pub fn point_surface_to_model(&self, _point: &Point<2>) -> Point<3> { + // TASK: Implement. + todo!() + } + + /// Convert a vector in surface coordinates to model coordinates + pub fn vector_surface_to_model(&self, _vector: &Vector<2>) -> Vector<3> { + // TASK: Implement. + todo!() + } +} + +// TASK: Add test suite.