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 {
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(
origin: Point<3>,
direction: Vector<3>,
) -> Self {
let line = Line { direction };
Self {
origin,
floating: Box::new(line),
}
Self::from_origin_and_curve(origin, line)
}
pub fn line_from_points([a, b]: [Point<3>; 2]) -> Self {

View File

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

View File

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