#[repr(C)]pub struct Matrix4<S> {
pub x: Vector4<S>,
pub y: Vector4<S>,
pub z: Vector4<S>,
pub w: Vector4<S>,
}Expand description
A 4 x 4, column major matrix
This type is marked as #[repr(C)].
Fields
x: Vector4<S>The first column of the matrix.
y: Vector4<S>The second column of the matrix.
z: Vector4<S>The third column of the matrix.
w: Vector4<S>The fourth column of the matrix.
Implementations
sourceimpl<S> Matrix4<S>
impl<S> Matrix4<S>
sourceimpl<S> Matrix4<S> where
S: BaseFloat,
impl<S> Matrix4<S> where
S: BaseFloat,
sourcepub fn from_translation(v: Vector3<S>) -> Matrix4<S>
pub fn from_translation(v: Vector3<S>) -> Matrix4<S>
Create a homogeneous transformation matrix from a translation vector.
sourcepub fn from_scale(value: S) -> Matrix4<S>
pub fn from_scale(value: S) -> Matrix4<S>
Create a homogeneous transformation matrix from a scale value.
sourcepub fn from_nonuniform_scale(x: S, y: S, z: S) -> Matrix4<S>
pub fn from_nonuniform_scale(x: S, y: S, z: S) -> Matrix4<S>
Create a homogeneous transformation matrix from a set of scale values.
sourcepub fn look_at_dir(
eye: Point3<S>,
dir: Vector3<S>,
up: Vector3<S>
) -> Matrix4<S>
👎 Deprecated: Use Matrix4::look_to_rh
pub fn look_at_dir(
eye: Point3<S>,
dir: Vector3<S>,
up: Vector3<S>
) -> Matrix4<S>
Use Matrix4::look_to_rh
Create a homogeneous transformation matrix that will cause a vector to point at
dir, using up for orientation.
sourcepub fn look_to_rh(eye: Point3<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S>
pub fn look_to_rh(eye: Point3<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S>
Create a homogeneous transformation matrix that will cause a vector to point at
dir, using up for orientation.
sourcepub fn look_to_lh(eye: Point3<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S>
pub fn look_to_lh(eye: Point3<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S>
Create a homogeneous transformation matrix that will cause a vector to point at
dir, using up for orientation.
sourcepub fn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
👎 Deprecated: Use Matrix4::look_at_rh
pub fn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
Use Matrix4::look_at_rh
Create a homogeneous transformation matrix that will cause a vector to point at
center, using up for orientation.
sourcepub fn look_at_rh(
eye: Point3<S>,
center: Point3<S>,
up: Vector3<S>
) -> Matrix4<S>
pub fn look_at_rh(
eye: Point3<S>,
center: Point3<S>,
up: Vector3<S>
) -> Matrix4<S>
Create a homogeneous transformation matrix that will cause a vector to point at
center, using up for orientation.
sourcepub fn look_at_lh(
eye: Point3<S>,
center: Point3<S>,
up: Vector3<S>
) -> Matrix4<S>
pub fn look_at_lh(
eye: Point3<S>,
center: Point3<S>,
up: Vector3<S>
) -> Matrix4<S>
Create a homogeneous transformation matrix that will cause a vector to point at
center, using up for orientation.
sourcepub fn from_angle_x<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
pub fn from_angle_x<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
Create a homogeneous transformation matrix from a rotation around the x axis (pitch).
sourcepub fn from_angle_y<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
pub fn from_angle_y<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
Create a homogeneous transformation matrix from a rotation around the y axis (yaw).
sourcepub fn from_angle_z<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
pub fn from_angle_z<A>(theta: A) -> Matrix4<S> where
A: Into<Rad<S>>,
Create a homogeneous transformation matrix from a rotation around the z axis (roll).
Trait Implementations
sourceimpl<S> AbsDiffEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> AbsDiffEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
fn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &Matrix4<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Matrix4<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of [AbsDiffEq::abs_diff_eq].
sourceimpl<S> AddAssign<Matrix4<S>> for Matrix4<S> where
S: BaseFloat + AddAssign<S>,
impl<S> AddAssign<Matrix4<S>> for Matrix4<S> where
S: BaseFloat + AddAssign<S>,
sourcefn add_assign(&mut self, other: Matrix4<S>)
fn add_assign(&mut self, other: Matrix4<S>)
Performs the += operation. Read more
sourceimpl<S> DivAssign<S> for Matrix4<S> where
S: BaseFloat + DivAssign<S>,
impl<S> DivAssign<S> for Matrix4<S> where
S: BaseFloat + DivAssign<S>,
sourcefn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the /= operation. Read more
sourceimpl<S, R> From<Decomposed<Vector3<S>, R>> for Matrix4<S> where
S: BaseFloat,
R: Rotation3<Scalar = S>,
impl<S, R> From<Decomposed<Vector3<S>, R>> for Matrix4<S> where
S: BaseFloat,
R: Rotation3<Scalar = S>,
sourcefn from(dec: Decomposed<Vector3<S>, R>) -> Matrix4<S>
fn from(dec: Decomposed<Vector3<S>, R>) -> Matrix4<S>
Converts to this type from the input type.
sourceimpl<A> From<Euler<A>> for Matrix4<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
impl<A> From<Euler<A>> for Matrix4<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
sourceimpl<S> From<Perspective<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> From<Perspective<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn from(persp: Perspective<S>) -> Matrix4<S>
fn from(persp: Perspective<S>) -> Matrix4<S>
Converts to this type from the input type.
sourceimpl<S> From<PerspectiveFov<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> From<PerspectiveFov<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn from(persp: PerspectiveFov<S>) -> Matrix4<S>
fn from(persp: PerspectiveFov<S>) -> Matrix4<S>
Converts to this type from the input type.
sourceimpl<S> From<Quaternion<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> From<Quaternion<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn from(quat: Quaternion<S>) -> Matrix4<S>
fn from(quat: Quaternion<S>) -> Matrix4<S>
Convert the quaternion to a 4 x 4 rotation matrix.
sourceimpl<S> Matrix for Matrix4<S> where
S: BaseFloat,
impl<S> Matrix for Matrix4<S> where
S: BaseFloat,
sourcefn swap_columns(&mut self, a: usize, b: usize)
fn swap_columns(&mut self, a: usize, b: usize)
Swap two columns of this array.
sourcefn swap_elements(&mut self, a: (usize, usize), b: (usize, usize))
fn swap_elements(&mut self, a: (usize, usize), b: (usize, usize))
Swap the values at index a and b
sourcefn as_mut_ptr(&mut self) -> *mut Self::Scalar
fn as_mut_ptr(&mut self) -> *mut Self::Scalar
Get a mutable pointer to the first element of the array.
sourcefn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column
fn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column
Replace a column in the array.
sourceimpl<S> MulAssign<S> for Matrix4<S> where
S: BaseFloat + MulAssign<S>,
impl<S> MulAssign<S> for Matrix4<S> where
S: BaseFloat + MulAssign<S>,
sourcefn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the *= operation. Read more
sourceimpl<S> RelativeEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> RelativeEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
fn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Matrix4<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Matrix4<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> 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
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of [RelativeEq::relative_eq].
sourceimpl<S> RemAssign<S> for Matrix4<S> where
S: BaseFloat + RemAssign<S>,
impl<S> RemAssign<S> for Matrix4<S> where
S: BaseFloat + RemAssign<S>,
sourcefn rem_assign(&mut self, scalar: S)
fn rem_assign(&mut self, scalar: S)
Performs the %= operation. Read more
sourceimpl<S> SquareMatrix for Matrix4<S> where
S: BaseFloat,
impl<S> SquareMatrix for Matrix4<S> where
S: BaseFloat,
sourcefn from_value(value: S) -> Matrix4<S>
fn from_value(value: S) -> Matrix4<S>
Create a new diagonal matrix using the supplied value.
sourcefn from_diagonal(value: Vector4<S>) -> Matrix4<S>
fn from_diagonal(value: Vector4<S>) -> Matrix4<S>
Create a matrix from a non-uniform scale
sourcefn transpose_self(&mut self)
fn transpose_self(&mut self)
Transpose this matrix in-place.
sourcefn determinant(&self) -> S
fn determinant(&self) -> S
Take the determinant of this matrix.
sourcefn invert(&self) -> Option<Matrix4<S>>
fn invert(&self) -> Option<Matrix4<S>>
Invert this matrix, returning a new matrix. m.mul_m(m.invert()) is
the identity matrix. Returns None if this matrix is not invertible
(has a determinant of zero). Read more
sourcefn is_diagonal(&self) -> bool
fn is_diagonal(&self) -> bool
Test if this is a diagonal matrix. That is, every element outside of the diagonal is 0. Read more
sourcefn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
Test if this matrix is symmetric. That is, it is equal to its transpose. Read more
sourcefn identity() -> Self
fn identity() -> Self
The identity matrix. Multiplying this matrix with another should have no effect. Read more
sourcefn trace(&self) -> Self::Scalar
fn trace(&self) -> Self::Scalar
Return the trace of this matrix. That is, the sum of the diagonal.
sourcefn is_invertible(&self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
fn is_invertible(&self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
Test if this matrix is invertible.
sourcefn is_identity(&self) -> bool where
Self: UlpsEq<Self>,
fn is_identity(&self) -> bool where
Self: UlpsEq<Self>,
Test if this matrix is the identity matrix. That is, it is diagonal and every element in the diagonal is one. Read more
sourceimpl<S> SubAssign<Matrix4<S>> for Matrix4<S> where
S: BaseFloat + SubAssign<S>,
impl<S> SubAssign<Matrix4<S>> for Matrix4<S> where
S: BaseFloat + SubAssign<S>,
sourcefn sub_assign(&mut self, other: Matrix4<S>)
fn sub_assign(&mut self, other: Matrix4<S>)
Performs the -= operation. Read more
sourceimpl<S> Transform<Point3<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> Transform<Point3<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
fn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
Use look_at_rh or look_at_lh
Create a transformation that rotates a vector to look at center from
eye, using up for orientation. Read more
sourcefn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
fn look_at_lh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
Create a transformation that rotates a vector to look at center from
eye, using up for orientation. Read more
sourcefn look_at_rh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
fn look_at_rh(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>
Create a transformation that rotates a vector to look at center from
eye, using up for orientation. Read more
sourcefn transform_vector(&self, vec: Vector3<S>) -> Vector3<S>
fn transform_vector(&self, vec: Vector3<S>) -> Vector3<S>
Transform a vector using this transform.
sourcefn transform_point(&self, point: Point3<S>) -> Point3<S>
fn transform_point(&self, point: Point3<S>) -> Point3<S>
Transform a point using this transform.
sourcefn concat(&self, other: &Matrix4<S>) -> Matrix4<S>
fn concat(&self, other: &Matrix4<S>) -> Matrix4<S>
Combine this transform with another, yielding a new transformation which has the effects of both. Read more
sourcefn inverse_transform(&self) -> Option<Matrix4<S>>
fn inverse_transform(&self) -> Option<Matrix4<S>>
Create a transform that “un-does” this one.
sourcefn inverse_transform_vector(
&self,
vec: <P as EuclideanSpace>::Diff
) -> Option<<P as EuclideanSpace>::Diff>
fn inverse_transform_vector(
&self,
vec: <P as EuclideanSpace>::Diff
) -> Option<<P as EuclideanSpace>::Diff>
Inverse transform a vector using this transform
sourcefn concat_self(&mut self, other: &Self)
fn concat_self(&mut self, other: &Self)
Combine this transform with another, in-place.
sourceimpl<S> Transform3 for Matrix4<S> where
S: BaseFloat,
impl<S> Transform3 for Matrix4<S> where
S: BaseFloat,
type Scalar = S
sourceimpl<S> UlpsEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
impl<S> UlpsEq<Matrix4<S>> for Matrix4<S> where
S: BaseFloat,
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
sourceimpl<S> VectorSpace for Matrix4<S> where
S: BaseFloat,
impl<S> VectorSpace for Matrix4<S> where
S: BaseFloat,
impl<S> Copy for Matrix4<S> where
S: Copy,
impl<S> StructuralPartialEq for Matrix4<S>
impl<T: UniformDataType + PrimitiveDataType> UniformDataType for Matrix4<T>
Auto Trait Implementations
impl<S> RefUnwindSafe for Matrix4<S> where
S: RefUnwindSafe,
impl<S> Send for Matrix4<S> where
S: Send,
impl<S> Sync for Matrix4<S> where
S: Sync,
impl<S> Unpin for Matrix4<S> where
S: Unpin,
impl<S> UnwindSafe for Matrix4<S> where
S: 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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more