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
sourceimpl<T> Matrix3dTransform<T> where
T: CoordinateType,
impl<T> Matrix3dTransform<T> where
T: CoordinateType,
sourcepub fn new(m11: T, m12: T, m21: T, m22: T, m31: T, m32: T) -> Matrix3dTransform<T>
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.
sourcepub fn identity() -> Matrix3dTransform<T>
pub fn identity() -> Matrix3dTransform<T>
Get the identity transform.
sourcepub fn translate<V>(v: V) -> Matrix3dTransform<T> where
V: Into<Vector<T>>,
pub fn translate<V>(v: V) -> Matrix3dTransform<T> where
V: Into<Vector<T>>,
Create a translation by a vector.
sourcepub fn rotate90(angle: Angle) -> Matrix3dTransform<T>
pub fn rotate90(angle: Angle) -> Matrix3dTransform<T>
Create a rotation by an integer multiple of 90 degrees.
sourcepub fn scale(factor: T) -> Matrix3dTransform<T>
pub fn scale(factor: T) -> Matrix3dTransform<T>
Create a scaling by a factor.
sourcepub fn mirror_x() -> Matrix3dTransform<T>
pub fn mirror_x() -> Matrix3dTransform<T>
Mirror at the x-axis.
sourcepub fn mirror_y() -> Matrix3dTransform<T>
pub fn mirror_y() -> Matrix3dTransform<T>
Mirror at the y-axis.
sourcepub fn transform_point(&self, p: Point<T>) -> Point<T>
pub fn transform_point(&self, p: Point<T>) -> Point<T>
Apply the transformation to a single point.
sourcepub fn to_matrix3d(&self) -> Matrix3d<T>
pub fn to_matrix3d(&self) -> Matrix3d<T>
Return the 3x3 matrix describing this transformation.
sourcepub fn to_matrix2d(&self) -> Matrix2d<T>
pub fn to_matrix2d(&self) -> Matrix2d<T>
Return the 2x2 matrix that describes this transformation without any translation.
sourcepub fn determinant(&self) -> T
pub fn determinant(&self) -> T
Compute the determinant of the 3x3 matrix that describes this transformation.
sourcepub fn try_invert(&self) -> Option<Matrix3dTransform<T>>
pub fn try_invert(&self) -> Option<Matrix3dTransform<T>>
Get the inverse transformation if it exists.
sourcepub fn then(&self, t: &Matrix3dTransform<T>) -> Matrix3dTransform<T>
pub fn then(&self, t: &Matrix3dTransform<T>) -> Matrix3dTransform<T>
Return a new transformation that is equal to applying
first self
then t
.
sourcepub fn then_scale(&self, factor: T) -> Matrix3dTransform<T>
pub fn then_scale(&self, factor: T) -> Matrix3dTransform<T>
Create a new transformation with an additional scaling.
sourcepub fn then_translate<V>(&self, v: V) -> Matrix3dTransform<T> where
V: Into<Vector<T>>,
pub fn then_translate<V>(&self, v: V) -> Matrix3dTransform<T> where
V: Into<Vector<T>>,
Create a new transformation with an additional translation.
sourcepub fn then_rotate90(&self, angle: Angle) -> Matrix3dTransform<T>
pub fn then_rotate90(&self, angle: Angle) -> Matrix3dTransform<T>
Create a new transformation with an additional rotation by a multiple of 90 degrees.
sourcepub fn then_mirror_x(&self) -> Matrix3dTransform<T>
pub fn then_mirror_x(&self) -> Matrix3dTransform<T>
Create a new transformation with an additional mirroring at the x-axis.
sourcepub fn then_mirror_y(&self) -> Matrix3dTransform<T>
pub fn then_mirror_y(&self) -> Matrix3dTransform<T>
Create a new transformation with an additional mirroring at the y-axis.
sourcepub fn get_translation(&self) -> Vector<T>
pub fn get_translation(&self) -> Vector<T>
Get the translation part of this affine transformation.
sourceimpl<T> Matrix3dTransform<T> where
T: CoordinateType + Float,
impl<T> Matrix3dTransform<T> where
T: CoordinateType + Float,
sourcepub fn rotation(phi: T) -> Matrix3dTransform<T>
pub fn rotation(phi: T) -> Matrix3dTransform<T>
Create a rotation by an arbitrary angle (in radians).
sourcepub fn then_rotate(&self, phi: T) -> Matrix3dTransform<T>
pub fn then_rotate(&self, phi: T) -> Matrix3dTransform<T>
Create a new transformation with an additional rotation.
Trait Implementations
sourceimpl<T> Clone for Matrix3dTransform<T> where
T: Clone + CoordinateType,
impl<T> Clone for Matrix3dTransform<T> where
T: Clone + CoordinateType,
sourcefn clone(&self) -> Matrix3dTransform<T>
fn clone(&self) -> Matrix3dTransform<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T> Debug for Matrix3dTransform<T> where
T: Debug + CoordinateType,
impl<T> Debug for Matrix3dTransform<T> where
T: Debug + CoordinateType,
sourceimpl<'de, T> Deserialize<'de> for Matrix3dTransform<T> where
T: CoordinateType + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Matrix3dTransform<T> where
T: CoordinateType + Deserialize<'de>,
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Matrix3dTransform<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
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
sourceimpl<T> Hash for Matrix3dTransform<T> where
T: Hash + CoordinateType,
impl<T> Hash for Matrix3dTransform<T> where
T: Hash + CoordinateType,
sourceimpl<T> Mul<Matrix3dTransform<T>> for Matrix3dTransform<T> where
T: CoordinateType,
impl<T> Mul<Matrix3dTransform<T>> for Matrix3dTransform<T> where
T: CoordinateType,
sourcefn mul(
self,
rhs: Matrix3dTransform<T>
) -> <Matrix3dTransform<T> as Mul<Matrix3dTransform<T>>>::Output
fn mul(
self,
rhs: Matrix3dTransform<T>
) -> <Matrix3dTransform<T> as Mul<Matrix3dTransform<T>>>::Output
Shortcut for self.then(&rhs)
.
type Output = Matrix3dTransform<T>
type Output = Matrix3dTransform<T>
The resulting type after applying the *
operator.
sourceimpl<T> PartialEq<Matrix3dTransform<T>> for Matrix3dTransform<T> where
T: PartialEq<T> + CoordinateType,
impl<T> PartialEq<Matrix3dTransform<T>> for Matrix3dTransform<T> where
T: PartialEq<T> + CoordinateType,
sourcefn eq(&self, other: &Matrix3dTransform<T>) -> bool
fn eq(&self, other: &Matrix3dTransform<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Matrix3dTransform<T>) -> bool
fn ne(&self, other: &Matrix3dTransform<T>) -> bool
This method tests for !=
.
sourceimpl<T> Serialize for Matrix3dTransform<T> where
T: CoordinateType + Serialize,
impl<T> Serialize for Matrix3dTransform<T> where
T: CoordinateType + Serialize,
sourcefn 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,
Serialize this value into the given Serde serializer. Read more
impl<T> Eq for Matrix3dTransform<T> where
T: Eq + CoordinateType,
impl<T> StructuralEq for Matrix3dTransform<T> where
T: CoordinateType,
impl<T> StructuralPartialEq for Matrix3dTransform<T> where
T: CoordinateType,
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more