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

source

pub fn identity() -> Transformation

Returns the identity transform, leaving any transformed object unmodified.

source

pub fn translate(x: f64, y: f64) -> Transformation

Returns a translation by (x,y).

source

pub fn rotate(angle: f64) -> Transformation

Returns a rotatation by angle degrees.

source

pub fn reflect_vert() -> Transformation

Returns a reflection about the x-axis.

source

pub fn builder() -> TransformationBuilder

Returns a new TransformationBuilder.

source

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).

source

pub fn from_offset_and_orientation( offset: Point, orientation: impl Into<Orientation> ) -> Transformation

Creates a transform from an offset and Orientation.

source

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.

source

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).
source

pub fn offset_point(&self) -> Point

The point representing the translation of this transformation.

source

pub fn orientation(&self) -> Orientation

Returns an Orientation corresponding to this transformation.

source

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

§

type Epsilon = f64

Used for specifying relative comparisons.
source§

fn default_epsilon() -> <Transformation as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq(&self, other: &Transformation, epsilon: f64) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of [AbsDiffEq::abs_diff_eq].
source§

impl Clone for Transformation

source§

fn clone(&self) -> Transformation

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Transformation

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Transformation

source§

fn default() -> Transformation

Returns the “default value” for a type. Read more
source§

impl<T> From<T> for Transformation
where T: Into<Orientation>,

source§

fn from(value: T) -> Transformation

Converts to this type from the input type.
source§

impl PartialEq for Transformation

source§

fn eq(&self, other: &Transformation) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RelativeEq for Transformation

source§

fn default_max_relative() -> f64

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Transformation, epsilon: f64, max_relative: f64 ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of [RelativeEq::relative_eq].
source§

impl UlpsEq for Transformation

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq(&self, other: &Transformation, epsilon: f64, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of [UlpsEq::ulps_eq].
source§

impl Copy for Transformation

source§

impl StructuralPartialEq for Transformation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CustomHardwareType<Flipped<T>> for U

source§

fn from_layout_type(other: &Flipped<T>) -> U

Creates this layout type from another layout type.
source§

impl<T, U> CustomHardwareType<InOut<T>> for U

source§

fn from_layout_type(other: &InOut<T>) -> U

Creates this layout type from another layout type.
source§

impl<T, U> CustomHardwareType<Input<T>> for U

source§

fn from_layout_type(other: &Input<T>) -> U

Creates this layout type from another layout type.
source§

impl<T, U> CustomHardwareType<Output<T>> for U

source§

fn from_layout_type(other: &Output<T>) -> U

Creates this layout type from another layout type.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> Connect<&T> for T

source§

impl<T> Connect<T> for T

source§

impl<T> Primitive for T
where T: Clone + Send + Sync + Any,

source§

impl<T> Primitive for T