Struct bevy_rapier2d::prelude::nalgebra::Transform[][src]

#[repr(C)]
pub struct Transform<T, C, const D: usize> where
    C: TCategory,
    T: RealField,
    Const<D>: DimNameAdd<Const<1_usize>>,
    DefaultAllocator: Allocator<T, <Const<D> as DimNameAdd<Const<1_usize>>>::Output, <Const<D> as DimNameAdd<Const<1_usize>>>::Output>, 
{ /* fields omitted */ }
Expand description

A transformation matrix in homogeneous coordinates.

It is stored as a matrix with dimensions (D + 1, D + 1), e.g., it stores a 4x4 matrix for a 3D transformation.

Implementations

Creates a new transformation from the given homogeneous matrix. The transformation category of Self is not checked to be verified by the given matrix.

Retrieves the underlying matrix.

Examples


let m = Matrix3::new(1.0, 2.0, 0.0,
                     3.0, 4.0, 0.0,
                     0.0, 0.0, 1.0);
let t = Transform2::from_matrix_unchecked(m);
assert_eq!(t.into_inner(), m);
👎 Deprecated:

use .into_inner() instead

Retrieves the underlying matrix. Deprecated: Use Transform::into_inner instead.

A reference to the underlying matrix.

Examples


let m = Matrix3::new(1.0, 2.0, 0.0,
                     3.0, 4.0, 0.0,
                     0.0, 0.0, 1.0);
let t = Transform2::from_matrix_unchecked(m);
assert_eq!(*t.matrix(), m);

A mutable reference to the underlying matrix.

It is _unchecked because direct modifications of this matrix may break invariants identified by this transformation category.

Examples


let m = Matrix3::new(1.0, 2.0, 0.0,
                     3.0, 4.0, 0.0,
                     0.0, 0.0, 1.0);
let mut t = Transform2::from_matrix_unchecked(m);
t.matrix_mut_unchecked().m12 = 42.0;
t.matrix_mut_unchecked().m23 = 90.0;


let expected = Matrix3::new(1.0, 42.0, 0.0,
                            3.0, 4.0,  90.0,
                            0.0, 0.0,  1.0);
assert_eq!(*t.matrix(), expected);

Sets the category of this transform.

This can be done only if the new category is more general than the current one, e.g., a transform with category TProjective cannot be converted to a transform with category TAffine because not all projective transformations are affine (the other way-round is valid though).

👎 Deprecated:

This method is redundant with automatic Copy and the .clone() method and will be removed in a future release.

Clones this transform into one that owns its data.

Converts this transform into its equivalent homogeneous transformation matrix.

Examples


let m = Matrix3::new(1.0, 2.0, 0.0,
                     3.0, 4.0, 0.0,
                     0.0, 0.0, 1.0);
let t = Transform2::from_matrix_unchecked(m);
assert_eq!(t.into_inner(), m);

Attempts to invert this transformation. You may use .inverse instead of this transformation has a subcategory of TProjective (i.e. if it is a Projective{2,3} or Affine{2,3}).

Examples


let m = Matrix3::new(2.0, 2.0, -0.3,
                     3.0, 4.0, 0.1,
                     0.0, 0.0, 1.0);
let t = Transform2::from_matrix_unchecked(m);
let inv_t = t.try_inverse().unwrap();
assert_relative_eq!(t * inv_t, Transform2::identity());
assert_relative_eq!(inv_t * t, Transform2::identity());

// Non-invertible case.
let m = Matrix3::new(0.0, 2.0, 1.0,
                     3.0, 0.0, 5.0,
                     0.0, 0.0, 0.0);
let t = Transform2::from_matrix_unchecked(m);
assert!(t.try_inverse().is_none());

Inverts this transformation. Use .try_inverse if this transform has the TGeneral category (i.e., a Transform{2,3} may not be invertible).

Examples


let m = Matrix3::new(2.0, 2.0, -0.3,
                     3.0, 4.0, 0.1,
                     0.0, 0.0, 1.0);
let proj = Projective2::from_matrix_unchecked(m);
let inv_t = proj.inverse();
assert_relative_eq!(proj * inv_t, Projective2::identity());
assert_relative_eq!(inv_t * proj, Projective2::identity());

Attempts to invert this transformation in-place. You may use .inverse_mut instead of this transformation has a subcategory of TProjective.

Examples


let m = Matrix3::new(2.0, 2.0, -0.3,
                     3.0, 4.0, 0.1,
                     0.0, 0.0, 1.0);
let t = Transform2::from_matrix_unchecked(m);
let mut inv_t = t;
assert!(inv_t.try_inverse_mut());
assert_relative_eq!(t * inv_t, Transform2::identity());
assert_relative_eq!(inv_t * t, Transform2::identity());

// Non-invertible case.
let m = Matrix3::new(0.0, 2.0, 1.0,
                     3.0, 0.0, 5.0,
                     0.0, 0.0, 0.0);
let mut t = Transform2::from_matrix_unchecked(m);
assert!(!t.try_inverse_mut());

Inverts this transformation in-place. Use .try_inverse_mut if this transform has the TGeneral category (it may not be invertible).

Examples


let m = Matrix3::new(2.0, 2.0, -0.3,
                     3.0, 4.0, 0.1,
                     0.0, 0.0, 1.0);
let proj = Projective2::from_matrix_unchecked(m);
let mut inv_t = proj;
inv_t.inverse_mut();
assert_relative_eq!(proj * inv_t, Projective2::identity());
assert_relative_eq!(inv_t * proj, Projective2::identity());

Transform the given point by this transformation.

This is the same as the multiplication self * pt.

Transform the given vector by this transformation, ignoring the translational component of the transformation.

This is the same as the multiplication self * v.

Transform the given point by the inverse of this transformation. This may be cheaper than inverting the transformation and transforming the point.

Transform the given vector by the inverse of this transformation. This may be cheaper than inverting the transformation and transforming the vector.

A mutable reference to underlying matrix. Use .matrix_mut_unchecked instead if this transformation category is not TGeneral.

Creates a new identity transform.

Example


let pt = Point2::new(1.0, 2.0);
let t = Projective2::identity();
assert_eq!(t * pt, pt);

let aff = Affine2::identity();
assert_eq!(aff * pt, pt);

let aff = Transform2::identity();
assert_eq!(aff * pt, pt);

// Also works in 3D.
let pt = Point3::new(1.0, 2.0, 3.0);
let t = Projective3::identity();
assert_eq!(t * pt, pt);

let aff = Affine3::identity();
assert_eq!(aff * pt, pt);

let aff = Transform3::identity();
assert_eq!(aff * pt, pt);

Trait Implementations

Used for specifying relative comparisons.

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

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

The inverse of [AbsDiffEq::abs_diff_eq].

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the conversion.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

Creates a new identity transform.

Sets self to the multiplicative identity element of Self, 1.

Returns true if self is equal to the multiplicative identity. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

The inverse of [RelativeEq::relative_eq].

The type of the elements of each lane of this SIMD value.

Type of the result of comparing two SIMD values like self.

The number of lanes of this SIMD value.

Initializes an SIMD value with each lanes set to val.

Extracts the i-th lane of self. Read more

Extracts the i-th lane of self without bound-checking.

Replaces the i-th lane of self by val. Read more

Replaces the i-th lane of self by val without bound-checking.

Merges self and other depending on the lanes of cond. Read more

Applies a function to each lane of self. Read more

Applies a function to each lane of self paired with the corresponding lane of b. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

The inclusion map: converts self to the equivalent element of its superset.

Checks if element is actually part of the subset Self (and can be converted to it).

Use with care! Same as self.to_superset but without any property checks. Always succeeds.

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

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

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

The inverse of [UlpsEq::ulps_eq].

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Performs the conversion.

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

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

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.

Tests if Self the same as the type T Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.