Struct substrate::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() -> Transformation
pub fn identity() -> Transformation
Returns the identity transform, leaving any transformed object unmodified.
sourcepub fn translate(x: f64, y: f64) -> Transformation
pub fn translate(x: f64, y: f64) -> Transformation
Returns a translation by (x,y)
.
sourcepub fn rotate(angle: f64) -> Transformation
pub fn rotate(angle: f64) -> Transformation
Returns a rotatation by angle
degrees.
sourcepub fn reflect_vert() -> Transformation
pub fn reflect_vert() -> Transformation
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) -> Transformation
pub fn from_offset(offset: Point) -> Transformation
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>
) -> Transformation
pub fn from_offset_and_orientation( offset: Point, orientation: impl Into<Orientation> ) -> Transformation
Creates a transform from an offset and Orientation
.
sourcepub fn from_opts(
offset: Point,
reflect_vert: bool,
angle: f64
) -> Transformation
pub fn from_opts( offset: Point, reflect_vert: bool, angle: f64 ) -> Transformation
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() -> <Transformation as AbsDiffEq>::Epsilon
fn default_epsilon() -> <Transformation as AbsDiffEq>::Epsilon
source§fn abs_diff_eq(&self, other: &Transformation, epsilon: f64) -> bool
fn abs_diff_eq(&self, other: &Transformation, 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§fn default() -> Transformation
fn default() -> Transformation
source§impl<T> From<T> for Transformationwhere
T: Into<Orientation>,
impl<T> From<T> for Transformationwhere
T: Into<Orientation>,
source§fn from(value: T) -> Transformation
fn from(value: T) -> Transformation
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: &Transformation,
epsilon: f64,
max_relative: f64
) -> bool
fn relative_eq( &self, other: &Transformation, 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
].source§impl UlpsEq for Transformation
impl UlpsEq for Transformation
impl Copy for Transformation
impl StructuralPartialEq for Transformation
Auto Trait Implementations§
impl RefUnwindSafe for Transformation
impl Send for Transformation
impl Sync for Transformation
impl Unpin for Transformation
impl UnwindSafe for Transformation
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Flipped<T>) -> U
fn from_layout_type(other: &Flipped<T>) -> U
source§impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &InOut<T>) -> U
fn from_layout_type(other: &InOut<T>) -> U
source§impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Input<T>) -> U
fn from_layout_type(other: &Input<T>) -> U
source§impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Output<T>) -> U
fn from_layout_type(other: &Output<T>) -> U
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request