mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 10:28:27 +00:00
Prepare to support other curves beside lines
This commit is contained in:
parent
2cb597c31e
commit
313d9713f0
@ -1,4 +1,4 @@
|
||||
use fj_math::Vector;
|
||||
use fj_math::{Line, Transform, Vector};
|
||||
|
||||
pub trait CurveGeometry {
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
||||
@ -9,3 +9,10 @@ impl CurveGeometry for () {
|
||||
Box::new(())
|
||||
}
|
||||
}
|
||||
|
||||
impl CurveGeometry for Line<3> {
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry> {
|
||||
let translated = self.transform(&Transform::translation(offset));
|
||||
Box::new(translated)
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use fj_math::Line;
|
||||
|
||||
use crate::geometry::CurveGeometry;
|
||||
|
||||
use super::vertex::Vertex;
|
||||
@ -7,9 +9,12 @@ pub struct Curve {
|
||||
}
|
||||
|
||||
impl Curve {
|
||||
pub fn line_from_vertices(_: [&Vertex; 2]) -> Self {
|
||||
pub fn line_from_vertices(vertices: [&Vertex; 2]) -> Self {
|
||||
let points = vertices.map(|vertex| vertex.point);
|
||||
let (line, _) = Line::from_points(points);
|
||||
|
||||
Self {
|
||||
geometry: Box::new(()),
|
||||
geometry: Box::new(line),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user