Add CurveGeometry::point_from_local

This commit is contained in:
Hanno Braun 2025-04-08 11:34:28 +02:00
parent e643be2974
commit e47df86f4b
2 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -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> {