Struct geometry::transform::Transformation
source · pub struct Transformation { /* private fields */ }
Expand description
A transformation representing translation, rotation, and reflection of geometry.
This object does not support scaling of geometry, and as such all transformation matrices should be unitary.
Implementations§
source§impl Transformation
impl Transformation
sourcepub fn identity() -> Self
pub fn identity() -> Self
Returns the identity transform, leaving any transformed object unmodified.
sourcepub fn reflect_vert() -> Self
pub fn reflect_vert() -> Self
Returns a reflection about the x-axis.
sourcepub fn builder() -> TransformationBuilder
pub fn builder() -> TransformationBuilder
Returns a new TransformationBuilder
.
sourcepub fn from_offset(offset: Point) -> Self
pub fn from_offset(offset: Point) -> Self
Creates a transform from only an offset.
The resulting transformation will apply only a translation (i.e. no rotations/reflections).
sourcepub fn from_offset_and_orientation(
offset: Point,
orientation: impl Into<Orientation>
) -> Self
pub fn from_offset_and_orientation( offset: Point, orientation: impl Into<Orientation> ) -> Self
Creates a transform from an offset and Orientation
.
sourcepub fn from_opts(offset: Point, reflect_vert: bool, angle: f64) -> Self
pub fn from_opts(offset: Point, reflect_vert: bool, angle: f64) -> Self
Creates a transform from an offset, angle, and a bool indicating whether or not to reflect vertically.
sourcepub fn cascade(parent: Transformation, child: Transformation) -> Transformation
pub fn cascade(parent: Transformation, child: Transformation) -> Transformation
Create a new Transformation
that is the cascade of parent
and child
.
“Parents” and “children” refer to typical layout-instance hierarchies, in which each layer of instance has a nested set of transformations relative to its top-level parent.
Note this operation is not commutative. For example the set of transformations:
- (a) Reflect vertically, then
- (b) Translate by (1,1)
- (c) Place a point at (local coordinate) (1,1) Lands said point at (2,-2) in top-level space, whereas reversing the order of (a) and (b) lands it at (2,0).
sourcepub fn offset_point(&self) -> Point
pub fn offset_point(&self) -> Point
The point representing the translation of this transformation.
sourcepub fn orientation(&self) -> Orientation
pub fn orientation(&self) -> Orientation
Returns an Orientation
corresponding to this transformation.
sourcepub fn inv(&self) -> Transformation
pub fn inv(&self) -> Transformation
Returns the inverse Transformation
of self
.
§Examples
use geometry::transform::Transformation;
use approx::assert_relative_eq;
let trans = Transformation::cascade(
Transformation::rotate(90.),
Transformation::translate(5., 10.),
);
let inv = trans.inv();
assert_relative_eq!(Transformation::cascade(inv, trans), Transformation::identity());
Trait Implementations§
source§impl AbsDiffEq for Transformation
impl AbsDiffEq for Transformation
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
source§fn abs_diff_eq(&self, other: &Self, epsilon: f64) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: f64) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
].source§impl Clone for Transformation
impl Clone for Transformation
source§fn clone(&self) -> Transformation
fn clone(&self) -> Transformation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Transformation
impl Debug for Transformation
source§impl Default for Transformation
impl Default for Transformation
source§impl<T> From<T> for Transformationwhere
T: Into<Orientation>,
impl<T> From<T> for Transformationwhere
T: Into<Orientation>,
source§impl PartialEq for Transformation
impl PartialEq for Transformation
source§fn eq(&self, other: &Transformation) -> bool
fn eq(&self, other: &Transformation) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl RelativeEq for Transformation
impl RelativeEq for Transformation
source§fn default_max_relative() -> f64
fn default_max_relative() -> f64
source§fn relative_eq(&self, other: &Self, epsilon: f64, max_relative: f64) -> bool
fn relative_eq(&self, other: &Self, epsilon: f64, max_relative: f64) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
RelativeEq::relative_eq
].