pub struct Transformation { /* private fields */ }
Expand description
A transformation representing a Manhattan translation, rotation, and/or 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: i64, y: i64) -> Transformation
pub fn translate(x: i64, y: i64) -> Transformation
Returns a translation by (x,y)
.
Sourcepub fn translate_ref(&self, x: i64, y: i64) -> Transformation
pub fn translate_ref(&self, x: i64, y: i64) -> Transformation
Translates the current transformation by (x, y)
, returning a new Transformation
.
Sourcepub fn rotate(angle: Rotation) -> Transformation
pub fn rotate(angle: Rotation) -> 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: Rotation,
) -> Transformation
pub fn from_opts( offset: Point, reflect_vert: bool, angle: Rotation, ) -> 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 geometry::transform::Rotation;
let trans = Transformation::cascade(
Transformation::rotate(Rotation::R90),
Transformation::translate(5, 10),
);
let inv = trans.inv();
assert_eq!(Transformation::cascade(inv, trans), Transformation::identity());
assert_eq!(Transformation::cascade(trans, inv), Transformation::identity());
Trait Implementations§
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<'de> Deserialize<'de> for Transformation
impl<'de> Deserialize<'de> for Transformation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transformation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transformation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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 Hash for Transformation
impl Hash for Transformation
Source§impl PartialEq for Transformation
impl PartialEq for Transformation
Source§impl Serialize for Transformation
impl Serialize for Transformation
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Transformation
impl Eq for Transformation
impl StructuralPartialEq for Transformation
Auto Trait Implementations§
impl Freeze for Transformation
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
, which can then be
downcast
into Box<dyn 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>
, which 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> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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