From b82849feb949bcf6f1761e9705245798909dbe72 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 9 Feb 2022 15:21:39 +0100 Subject: [PATCH] WIP Add `Edge::sweep_vertex` --- src/kernel/topology/edges.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/kernel/topology/edges.rs b/src/kernel/topology/edges.rs index 8238e9c02..d0bd6c2d7 100644 --- a/src/kernel/topology/edges.rs +++ b/src/kernel/topology/edges.rs @@ -2,8 +2,8 @@ use nalgebra::vector; use parry3d_f64::math::Isometry; use crate::{ - kernel::geometry::{Circle, Curve}, - math::Point, + kernel::geometry::{Circle, Curve, Line}, + math::{Point, Vector}, }; use super::vertices::Vertex; @@ -131,6 +131,29 @@ impl Edge { } } + /// Construct an edge by sweeping a vertex + /// + /// Only sweeps along the positive direction of the z axis are supported. + /// + /// You must not use this method to create multiple instances of `Edge` that + /// refer to the same edge. + /// + /// TASK: Complete this doc comment. Look at `Vertex::create_at` for more + /// info. + // TASK: Un-suppress warning. + #[allow(unused)] + pub fn sweep_vertex(vertex: Vertex<3>, path: Vector<1>) -> Self { + let line = Line { + origin: *vertex.location(), + direction: vector![0., 0., path.x], + }; + + let a = vertex; + let b = Vertex::create_at(line.origin + line.direction); + + Self::new(Curve::Line(line), Some([a, b])) + } + /// Create an arc /// /// So far, the name of this method is a bit ambitious, as only full circles