mirror of https://github.com/hannobraun/Fornjot
Merge pull request #1313 from hannobraun/transform
Simplify `GlobalPath` transforms
This commit is contained in:
commit
b7e48f4669
|
@ -4,7 +4,6 @@ mod curve;
|
||||||
mod cycle;
|
mod cycle;
|
||||||
mod edge;
|
mod edge;
|
||||||
mod face;
|
mod face;
|
||||||
mod path;
|
|
||||||
mod shell;
|
mod shell;
|
||||||
mod sketch;
|
mod sketch;
|
||||||
mod solid;
|
mod solid;
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
use fj_math::Transform;
|
|
||||||
|
|
||||||
use crate::{objects::Objects, path::GlobalPath, validate::ValidationError};
|
|
||||||
|
|
||||||
use super::TransformObject;
|
|
||||||
|
|
||||||
impl TransformObject for GlobalPath {
|
|
||||||
fn transform(
|
|
||||||
self,
|
|
||||||
transform: &Transform,
|
|
||||||
_: &Objects,
|
|
||||||
) -> Result<Self, ValidationError> {
|
|
||||||
match self {
|
|
||||||
Self::Circle(curve) => {
|
|
||||||
Ok(Self::Circle(transform.transform_circle(&curve)))
|
|
||||||
}
|
|
||||||
Self::Line(curve) => {
|
|
||||||
Ok(Self::Line(transform.transform_line(&curve)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ impl TransformObject for Handle<Surface> {
|
||||||
objects: &Objects,
|
objects: &Objects,
|
||||||
) -> Result<Self, ValidationError> {
|
) -> Result<Self, ValidationError> {
|
||||||
Ok(objects.surfaces.insert(Surface::new(
|
Ok(objects.surfaces.insert(Surface::new(
|
||||||
self.u().transform(transform, objects)?,
|
self.u().transform(transform),
|
||||||
transform.transform_vector(&self.v()),
|
transform.transform_vector(&self.v()),
|
||||||
))?)
|
))?)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
//! [`Surface`]: crate::objects::Surface
|
//! [`Surface`]: crate::objects::Surface
|
||||||
//! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
|
//! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
|
||||||
|
|
||||||
use fj_math::{Circle, Line, Point, Scalar, Vector};
|
use fj_math::{Circle, Line, Point, Scalar, Transform, Vector};
|
||||||
|
|
||||||
/// A path through surface (2D) space
|
/// A path through surface (2D) space
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||||
|
@ -141,4 +141,15 @@ impl GlobalPath {
|
||||||
Self::Line(line) => line.vector_from_line_coords(vector),
|
Self::Line(line) => line.vector_from_line_coords(vector),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Transform the path
|
||||||
|
#[must_use]
|
||||||
|
pub fn transform(self, transform: &Transform) -> Self {
|
||||||
|
match self {
|
||||||
|
Self::Circle(curve) => {
|
||||||
|
Self::Circle(transform.transform_circle(&curve))
|
||||||
|
}
|
||||||
|
Self::Line(curve) => Self::Line(transform.transform_line(&curve)),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue