mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-03 17:38:27 +00:00
Prepare to support curved sweeps
This commit is contained in:
parent
9c63f68cce
commit
f81cb922b9
@ -81,6 +81,7 @@ pub trait CurveGeometry {
|
||||
fn clone_curve_geometry(&self) -> FloatingCurve;
|
||||
fn vector_from_local_point(&self, point: Point<1>) -> Vector<3>;
|
||||
fn project_vector(&self, vector: Vector<3>) -> Point<1>;
|
||||
fn flip(&self) -> FloatingCurve;
|
||||
|
||||
/// # Approximate the curve
|
||||
///
|
||||
@ -107,6 +108,13 @@ impl CurveGeometry for Circle {
|
||||
self.project_vector(vector)
|
||||
}
|
||||
|
||||
fn flip(&self) -> FloatingCurve {
|
||||
Box::new(Circle {
|
||||
a: self.a,
|
||||
b: -self.b,
|
||||
})
|
||||
}
|
||||
|
||||
fn approximate(
|
||||
&self,
|
||||
boundary: [Point<1>; 2],
|
||||
@ -131,6 +139,12 @@ impl CurveGeometry for Line {
|
||||
self.project_vector(vector)
|
||||
}
|
||||
|
||||
fn flip(&self) -> FloatingCurve {
|
||||
Box::new(Line {
|
||||
direction: -self.direction,
|
||||
})
|
||||
}
|
||||
|
||||
fn approximate(&self, _: [Point<1>; 2], _: Tolerance) -> Vec<Point<1>> {
|
||||
vec![]
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use fj_math::{Point, Vector};
|
||||
|
||||
use super::{AnchoredCurve, Line};
|
||||
use super::{AnchoredCurve, Line, curve::FloatingCurve};
|
||||
|
||||
pub struct SweptCurve {
|
||||
pub u: AnchoredCurve,
|
||||
pub v: Vector<3>,
|
||||
pub v: FloatingCurve,
|
||||
}
|
||||
|
||||
impl SweptCurve {
|
||||
@ -20,7 +20,7 @@ impl SweptCurve {
|
||||
origin,
|
||||
floating: Box::new(u),
|
||||
},
|
||||
v: v.direction,
|
||||
v: Box::new(v),
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,8 @@ impl SweptCurve {
|
||||
|
||||
pub fn point_from_local(&self, point: impl Into<Point<2>>) -> Point<3> {
|
||||
let [u, v] = point.into().coords.components;
|
||||
self.u.point_from_local([u]) + self.v * v
|
||||
self.u.point_from_local([u])
|
||||
+ self.v.vector_from_local_point(Point::from([v]))
|
||||
}
|
||||
|
||||
pub fn project_point(&self, point: impl Into<Point<3>>) -> Point<2> {
|
||||
@ -40,8 +41,10 @@ impl SweptCurve {
|
||||
let u = self.u.project_point(point);
|
||||
let v = {
|
||||
let origin = self.u.point_from_local(u);
|
||||
let line =
|
||||
AnchoredCurve::line_from_origin_and_direction(origin, self.v);
|
||||
let line = AnchoredCurve {
|
||||
origin,
|
||||
floating: self.v.clone_curve_geometry(),
|
||||
};
|
||||
|
||||
line.project_point(point)
|
||||
};
|
||||
@ -52,14 +55,14 @@ impl SweptCurve {
|
||||
pub fn flip(&self) -> Self {
|
||||
Self {
|
||||
u: self.u.clone(),
|
||||
v: -self.v,
|
||||
v: self.v.flip(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn translate(&self, offset: impl Into<Vector<3>>) -> Self {
|
||||
Self {
|
||||
u: self.u.translate(offset),
|
||||
v: self.v,
|
||||
v: self.v.clone_curve_geometry(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user