Add AnchoredCurve::from_origin_and_curve

This commit is contained in:
Hanno Braun 2025-05-05 11:49:24 +02:00
parent cc183bc469
commit 38d62383af
3 changed files with 15 additions and 12 deletions

View File

@ -23,16 +23,23 @@ pub struct AnchoredCurve {
} }
impl AnchoredCurve { impl AnchoredCurve {
pub fn from_origin_and_curve(
origin: Point<3>,
curve: impl CurveGeometry + 'static,
) -> Self {
Self {
origin,
floating: Box::new(curve),
}
}
pub fn line_from_origin_and_direction( pub fn line_from_origin_and_direction(
origin: Point<3>, origin: Point<3>,
direction: Vector<3>, direction: Vector<3>,
) -> Self { ) -> Self {
let line = Line { direction }; let line = Line { direction };
Self { Self::from_origin_and_curve(origin, line)
origin,
floating: Box::new(line),
}
} }
pub fn line_from_points([a, b]: [Point<3>; 2]) -> Self { pub fn line_from_points([a, b]: [Point<3>; 2]) -> Self {

View File

@ -110,10 +110,9 @@ impl Sketch {
}; };
Handle::new(Curve { Handle::new(Curve {
geometry: AnchoredCurve { geometry: AnchoredCurve::from_origin_and_curve(
origin, origin, circle,
floating: Box::new(circle), ),
},
}) })
} }
SketchSegment::Line { .. } => { SketchSegment::Line { .. } => {

View File

@ -16,10 +16,7 @@ impl SweptCurve {
let [u, v] = axes.map(Into::into).map(|direction| Line { direction }); let [u, v] = axes.map(Into::into).map(|direction| Line { direction });
Self { Self {
u: AnchoredCurve { u: AnchoredCurve::from_origin_and_curve(origin, u),
origin,
floating: Box::new(u),
},
v: Box::new(v), v: Box::new(v),
} }
} }