mirror of
https://github.com/hannobraun/Fornjot
synced 2025-08-07 09:46:06 +00:00
Add CurveGeometry::project_point
This commit is contained in:
parent
327b393441
commit
958e27ca10
@ -2,6 +2,7 @@ use fj_math::{Line, Point, Transform, Vector};
|
|||||||
|
|
||||||
pub trait CurveGeometry {
|
pub trait CurveGeometry {
|
||||||
fn point_from_local(&self, point: Point<1>) -> Point<3>;
|
fn point_from_local(&self, point: Point<1>) -> Point<3>;
|
||||||
|
fn project_point(&self, point: Point<3>) -> Point<1>;
|
||||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,6 +11,10 @@ impl CurveGeometry for Line<3> {
|
|||||||
self.point_from_line_coords(point)
|
self.point_from_line_coords(point)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn project_point(&self, point: Point<3>) -> Point<1> {
|
||||||
|
self.point_to_line_coords(point)
|
||||||
|
}
|
||||||
|
|
||||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry> {
|
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry> {
|
||||||
let translated = self.transform(&Transform::translation(offset));
|
let translated = self.transform(&Transform::translation(offset));
|
||||||
Box::new(translated)
|
Box::new(translated)
|
||||||
|
@ -25,7 +25,7 @@ impl SweptCurve {
|
|||||||
pub fn project_point(&self, point: impl Into<Point<3>>) -> Point<2> {
|
pub fn project_point(&self, point: impl Into<Point<3>>) -> Point<2> {
|
||||||
let point = point.into();
|
let point = point.into();
|
||||||
|
|
||||||
let u = self.curve.point_to_line_coords(point);
|
let u = self.curve.project_point(point);
|
||||||
let v = {
|
let v = {
|
||||||
let origin = self.curve.point_from_line_coords(u);
|
let origin = self.curve.point_from_line_coords(u);
|
||||||
let line = Line::from_origin_and_direction(origin, self.path);
|
let line = Line::from_origin_and_direction(origin, self.path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user