Struct libreda_db::layout::prelude::Matrix3dTransform

source ·
pub struct Matrix3dTransform<T>
where T: CoordinateType,
{ pub m11: T, pub m12: T, pub m21: T, pub m22: T, pub m31: T, pub m32: T, }
Expand description

Affine transformation represented as a 3x3 matrix like:

m11 m12 0
m21 m22 0
m31 m32 1

Fields§

§m11: T

m11

§m12: T

m12

§m21: T

m21

§m22: T

m22

§m31: T

m31. Used to express the x component of the translation.

§m32: T

m32. Used to express the y component of the translation.

Implementations§

source§

impl<T> Matrix3dTransform<T>
where T: CoordinateType,

source

pub fn new( m11: T, m12: T, m21: T, m22: T, m31: T, m32: T, ) -> Matrix3dTransform<T>

Create a new transform based on the matrix elements.

source

pub fn identity() -> Matrix3dTransform<T>

Get the identity transform.

source

pub fn translate<V>(v: V) -> Matrix3dTransform<T>
where V: Into<Vector<T>>,

Create a translation by a vector.

source

pub fn rotate90(angle: Angle) -> Matrix3dTransform<T>

Create a rotation by an integer multiple of 90 degrees.

source

pub fn scale(factor: T) -> Matrix3dTransform<T>

Create a scaling by a factor.

source

pub fn mirror_x() -> Matrix3dTransform<T>

Mirror at the x-axis.

source

pub fn mirror_y() -> Matrix3dTransform<T>

Mirror at the y-axis.

source

pub fn transform_point(&self, p: Point<T>) -> Point<T>

Apply the transformation to a single point.

source

pub fn to_matrix3d(&self) -> Matrix3d<T>

Return the 3x3 matrix describing this transformation.

source

pub fn to_matrix2d(&self) -> Matrix2d<T>

Return the 2x2 matrix that describes this transformation without any translation.

source

pub fn determinant(&self) -> T

Compute the determinant of the 3x3 matrix that describes this transformation.

source

pub fn try_invert(&self) -> Option<Matrix3dTransform<T>>

Get the inverse transformation if it exists.

source

pub fn then(&self, t: &Matrix3dTransform<T>) -> Matrix3dTransform<T>

Return a new transformation that is equal to applying first self then t.

source

pub fn then_scale(&self, factor: T) -> Matrix3dTransform<T>

Create a new transformation with an additional scaling.

source

pub fn then_translate<V>(&self, v: V) -> Matrix3dTransform<T>
where V: Into<Vector<T>>,

Create a new transformation with an additional translation.

source

pub fn then_rotate90(&self, angle: Angle) -> Matrix3dTransform<T>

Create a new transformation with an additional rotation by a multiple of 90 degrees.

source

pub fn then_mirror_x(&self) -> Matrix3dTransform<T>

Create a new transformation with an additional mirroring at the x-axis.

source

pub fn then_mirror_y(&self) -> Matrix3dTransform<T>

Create a new transformation with an additional mirroring at the y-axis.

source

pub fn get_translation(&self) -> Vector<T>

Get the translation part of this affine transformation.

source§

impl<T> Matrix3dTransform<T>
where T: CoordinateType + Float,

source

pub fn rotation(phi: T) -> Matrix3dTransform<T>

Create a rotation by an arbitrary angle (in radians).

source

pub fn then_rotate(&self, phi: T) -> Matrix3dTransform<T>

Create a new transformation with an additional rotation.

Trait Implementations§

source§

impl<T> Clone for Matrix3dTransform<T>
where T: Clone + CoordinateType,

source§

fn clone(&self) -> Matrix3dTransform<T>

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<T> Debug for Matrix3dTransform<T>
where T: Debug + CoordinateType,

source§

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

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

impl<'de, T> Deserialize<'de> for Matrix3dTransform<T>
where T: CoordinateType + Deserialize<'de>,

source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Matrix3dTransform<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Hash for Matrix3dTransform<T>
where T: Hash + CoordinateType,

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> Mul for Matrix3dTransform<T>
where T: CoordinateType,

source§

fn mul(self, rhs: Matrix3dTransform<T>) -> <Matrix3dTransform<T> as Mul>::Output

Shortcut for self.then(&rhs).

§

type Output = Matrix3dTransform<T>

The resulting type after applying the * operator.
source§

impl<T> PartialEq for Matrix3dTransform<T>

source§

fn eq(&self, other: &Matrix3dTransform<T>) -> 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<T> Serialize for Matrix3dTransform<T>

source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Eq for Matrix3dTransform<T>
where T: Eq + CoordinateType,

source§

impl<T> StructuralPartialEq for Matrix3dTransform<T>
where T: CoordinateType,

Auto Trait Implementations§

§

impl<T> Freeze for Matrix3dTransform<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Matrix3dTransform<T>
where T: RefUnwindSafe,

§

impl<T> Send for Matrix3dTransform<T>
where T: Send,

§

impl<T> Sync for Matrix3dTransform<T>
where T: Sync,

§

impl<T> Unpin for Matrix3dTransform<T>
where T: Unpin,

§

impl<T> UnwindSafe for Matrix3dTransform<T>
where T: UnwindSafe,

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> IdType for T
where T: Debug + Clone + Eq + Hash + 'static,

source§

impl<T> IdTypeMT for T
where T: IdType + Sync + Send,

source§

impl<T> TextType for T
where T: Eq + Hash + Clone + Debug,