mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 18:38:28 +00:00
Add CurveGeometry::point_from_local
This commit is contained in:
parent
e643be2974
commit
e47df86f4b
@ -1,10 +1,15 @@
|
||||
use fj_math::{Line, Transform, Vector};
|
||||
use fj_math::{Line, Point, Transform, Vector};
|
||||
|
||||
pub trait CurveGeometry {
|
||||
fn point_from_local(&self, point: Point<1>) -> Point<3>;
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
||||
}
|
||||
|
||||
impl CurveGeometry for Line<3> {
|
||||
fn point_from_local(&self, point: Point<1>) -> Point<3> {
|
||||
self.point_from_line_coords(point)
|
||||
}
|
||||
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry> {
|
||||
let translated = self.transform(&Transform::translation(offset));
|
||||
Box::new(translated)
|
||||
|
@ -1,5 +1,7 @@
|
||||
use fj_math::{Line, Point, Transform, Vector};
|
||||
|
||||
use super::CurveGeometry;
|
||||
|
||||
pub struct SweptCurve {
|
||||
pub curve: Line<3>,
|
||||
pub path: Vector<3>,
|
||||
@ -29,7 +31,7 @@ impl SweptCurve {
|
||||
|
||||
pub fn point_from_local(&self, point: impl Into<Point<2>>) -> Point<3> {
|
||||
let [u, v] = point.into().coords.components;
|
||||
self.curve.point_from_line_coords(Point::from([u])) + self.v() * v
|
||||
self.curve.point_from_local(Point::from([u])) + self.v() * v
|
||||
}
|
||||
|
||||
pub fn project_point(&self, point: impl Into<Point<3>>) -> Point<2> {
|
||||
|
Loading…
Reference in New Issue
Block a user