Struct cgmath::Matrix4

source ·
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

Fields§

§x: Vector4<S>§y: Vector4<S>§z: Vector4<S>§w: Vector4<S>

Implementations§

source§

impl<S> Matrix4<S>

source

pub fn new( c0r0: S, c0r1: S, c0r2: S, c0r3: S, c1r0: S, c1r1: S, c1r2: S, c1r3: S, c2r0: S, c2r1: S, c2r2: S, c2r3: S, c3r0: S, c3r1: S, c3r2: S, c3r3: S ) -> Matrix4<S>

Create a new matrix, providing values for each index.

source

pub fn from_cols( c0: Vector4<S>, c1: Vector4<S>, c2: Vector4<S>, c3: Vector4<S> ) -> Matrix4<S>

Create a new matrix, providing columns.

source§

impl<S: BaseNum> Matrix4<S>

source

pub fn from_translation(v: Vector3<S>) -> Matrix4<S>

Create a translation matrix from a Vector3

source§

impl<S: BaseFloat> Matrix4<S>

source

pub fn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>

Create a transformation matrix that will cause a vector to point at dir, using up for orientation.

source§

impl<S: Copy + Neg<Output = S>> Matrix4<S>

source

pub fn neg_self(&mut self)

Negate this Matrix4 in-place.

Trait Implementations§

source§

impl<'a, 'b, S: BaseFloat> Add<&'a Matrix4<S>> for &'b Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Matrix4<S>) -> Matrix4<S>

Performs the + operation. Read more
source§

impl<S: BaseFloat> ApproxEq for Matrix4<S>

§

type Epsilon = S

source§

fn approx_eq_eps(&self, other: &Matrix4<S>, epsilon: &S) -> bool

source§

fn approx_epsilon() -> Self::Epsilon

source§

fn approx_eq(&self, other: &Self) -> bool

source§

impl<S> AsMut<[[S; 4]; 4]> for Matrix4<S>

source§

fn as_mut(&mut self) -> &mut [[S; 4]; 4]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<S> AsMut<[S; 16]> for Matrix4<S>

source§

fn as_mut(&mut self) -> &mut [S; 16]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<S> AsRef<[[S; 4]; 4]> for Matrix4<S>

source§

fn as_ref(&self) -> &[[S; 4]; 4]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S> AsRef<[S; 16]> for Matrix4<S>

source§

fn as_ref(&self) -> &[S; 16]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S: Clone> Clone for Matrix4<S>

source§

fn clone(&self) -> Matrix4<S>

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<S: BaseNum> Debug for Matrix4<S>

source§

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

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

impl<S: Decodable> Decodable for Matrix4<S>

source§

fn decode<__D: Decoder>(d: &mut __D) -> Result<Matrix4<S>, __D::Error>

Deserialize a value using a Decoder.
source§

impl<'a, S: BaseFloat> Div<S> for &'a Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the / operator.
source§

fn div(self, s: S) -> Matrix4<S>

Performs the / operation. Read more
source§

impl<S: Encodable> Encodable for Matrix4<S>

source§

fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>

Serialize a value using an Encoder.
source§

impl<'a, S> From<&'a [[S; 4]; 4]> for &'a Matrix4<S>

source§

fn from(m: &'a [[S; 4]; 4]) -> &'a Matrix4<S>

Converts to this type from the input type.
source§

impl<'a, S> From<&'a [S; 16]> for &'a Matrix4<S>

source§

fn from(m: &'a [S; 16]) -> &'a Matrix4<S>

Converts to this type from the input type.
source§

impl<'a, S> From<&'a mut [[S; 4]; 4]> for &'a mut Matrix4<S>

source§

fn from(m: &'a mut [[S; 4]; 4]) -> &'a mut Matrix4<S>

Converts to this type from the input type.
source§

impl<'a, S> From<&'a mut [S; 16]> for &'a mut Matrix4<S>

source§

fn from(m: &'a mut [S; 16]) -> &'a mut Matrix4<S>

Converts to this type from the input type.
source§

impl<S: Copy> From<[[S; 4]; 4]> for Matrix4<S>

source§

fn from(m: [[S; 4]; 4]) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseNum> From<AffineMatrix3<S>> for Matrix4<S>

source§

fn from(aff: AffineMatrix3<S>) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat, R: Rotation3<S>> From<Decomposed<Vector3<S>, R>> for Matrix4<S>

source§

fn from(dec: Decomposed<Vector3<S>, R>) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat> From<Matrix2<S>> for Matrix4<S>

source§

fn from(m: Matrix2<S>) -> Matrix4<S>

Clone the elements of a 2-dimensional matrix into the top-left corner of a 4-dimensional identity matrix.

source§

impl<S: BaseFloat> From<Matrix3<S>> for Matrix4<S>

source§

fn from(m: Matrix3<S>) -> Matrix4<S>

Clone the elements of a 3-dimensional matrix into the top-left corner of a 4-dimensional identity matrix.

source§

impl<S: BaseFloat> From<Ortho<S>> for Matrix4<S>

source§

fn from(ortho: Ortho<S>) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat + 'static> From<Perspective<S>> for Matrix4<S>

source§

fn from(persp: Perspective<S>) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat, A: Angle<S>> From<PerspectiveFov<S, A>> for Matrix4<S>

source§

fn from(persp: PerspectiveFov<S, A>) -> Matrix4<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat> From<Quaternion<S>> for Matrix4<S>

source§

fn from(quat: Quaternion<S>) -> Matrix4<S>

Convert the quaternion to a 4 x 4 rotation matrix

source§

impl<S> Index<usize> for Matrix4<S>

§

type Output = Vector4<S>

The returned type after indexing.
source§

fn index<'a>(&'a self, i: usize) -> &'a Vector4<S>

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

impl<S> IndexMut<usize> for Matrix4<S>

source§

fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vector4<S>

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

impl<S> Into<[[S; 4]; 4]> for Matrix4<S>

source§

fn into(self) -> [[S; 4]; 4]

Converts this type into the (usually inferred) input type.
source§

impl<S: BaseFloat> Matrix for Matrix4<S>

§

type Element = S

The type of the elements in the matrix.
§

type Column = Vector4<S>

The column vector of the matrix.
§

type Row = Vector4<S>

The row vector of the matrix.
§

type Transpose = Matrix4<S>

The type of the transposed matrix
source§

fn row(&self, r: usize) -> Vector4<S>

Get a row from this matrix by-value.
source§

fn swap_rows(&mut self, a: usize, b: usize)

Swap two rows of this array.
source§

fn swap_columns(&mut self, a: usize, b: usize)

Swap two columns of this array.
source§

fn swap_elements(&mut self, a: (usize, usize), b: (usize, usize))

Swap the values at index a and b
source§

fn zero() -> Matrix4<S>

Create a matrix with all of the elements set to zero.
source§

fn mul_m(&self, other: &Matrix4<S>) -> Matrix4<S>

Multiply the matrix by another matrix,
source§

fn mul_v(&self, v: Vector4<S>) -> Vector4<S>

Multiply the matrix by a column vector.
source§

fn mul_s(&self, s: S) -> Matrix4<S>

Multiply this matrix by a scalar, returning the new matrix.
source§

fn div_s(&self, s: S) -> Matrix4<S>

Divide this matrix by a scalar, returning the new matrix.
source§

fn mul_self_s(&mut self, s: S)

Multiply this matrix by a scalar, in-place.
source§

fn div_self_s(&mut self, s: S)

Divide this matrix by a scalar, in-place.
source§

fn transpose(&self) -> Matrix4<S>

Transpose this matrix, returning a new matrix.
source§

fn as_ptr(&self) -> *const Self::Element

Get the pointer to the first element of the array.
source§

fn as_mut_ptr(&mut self) -> *mut Self::Element

Get a mutable pointer to the first element of the array.
source§

fn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column

Replace a column in the array.
source§

impl<'a, 'b, S: BaseFloat> Mul<&'a Matrix4<S>> for &'b Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Matrix4<S>) -> Matrix4<S>

Performs the * operation. Read more
source§

impl<'a, 'b, S: BaseFloat> Mul<&'a Vector4<S>> for &'b Matrix4<S>

§

type Output = Vector4<S>

The resulting type after applying the * operator.
source§

fn mul(self, v: &'a Vector4<S>) -> Vector4<S>

Performs the * operation. Read more
source§

impl<'a, S: BaseFloat> Mul<S> for &'a Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the * operator.
source§

fn mul(self, s: S) -> Matrix4<S>

Performs the * operation. Read more
source§

impl<'a, S: BaseFloat> Mul<Vector4<S>> for &'a Matrix4<S>

§

type Output = Vector4<S>

The resulting type after applying the * operator.
source§

fn mul(self, v: Vector4<S>) -> Vector4<S>

Performs the * operation. Read more
source§

impl<S: BaseFloat> Neg for Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the - operator.
source§

fn neg(self) -> Matrix4<S>

Performs the unary - operation. Read more
source§

impl<S: PartialEq> PartialEq<Matrix4<S>> for Matrix4<S>

source§

fn eq(&self, other: &Matrix4<S>) -> 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<S: BaseFloat + Rand> Rand for Matrix4<S>

source§

fn rand<R: Rng>(rng: &mut R) -> Matrix4<S>

Generates a random instance of this type using the specified source of randomness.
source§

impl<'a, S: BaseFloat> Rem<S> for &'a Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the % operator.
source§

fn rem(self, s: S) -> Matrix4<S>

Performs the % operation. Read more
source§

impl<S: BaseFloat> SquareMatrix for Matrix4<S>

§

type ColumnRow = Vector4<S>

The row/column vector of the matrix. Read more
source§

fn from_value(value: S) -> Matrix4<S>

Create a new diagonal matrix using the supplied value.
source§

fn from_diagonal(value: Vector4<S>) -> Matrix4<S>

Create a matrix from a non-uniform scale
source§

fn one() -> Matrix4<S>

Create a matrix where the each element of the diagonal is equal to one.
source§

fn add_m(&self, m: &Matrix4<S>) -> Matrix4<S>

Add this matrix with another matrix, returning the new metrix.
source§

fn sub_m(&self, m: &Matrix4<S>) -> Matrix4<S>

Subtract another matrix from this matrix, returning the new matrix.
source§

fn add_self_m(&mut self, m: &Matrix4<S>)

Add this matrix with another matrix, in-place.
source§

fn sub_self_m(&mut self, m: &Matrix4<S>)

Subtract another matrix from this matrix, in-place.
source§

fn transpose_self(&mut self)

Transpose this matrix in-place.
source§

fn determinant(&self) -> S

Take the determinant of this matrix.
source§

fn diagonal(&self) -> Vector4<S>

Return a vector containing the diagonal of this matrix.
source§

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

fn is_diagonal(&self) -> bool

Test if this is a diagonal matrix. That is, every element outside of the diagonal is 0.
source§

fn is_symmetric(&self) -> bool

Test if this matrix is symmetric. That is, it is equal to its transpose.
source§

fn mul_self_m(&mut self, m: &Self)

Multiply this matrix by another matrix, in-place.
source§

fn trace(&self) -> Self::Element

Return the trace of this matrix. That is, the sum of the diagonal.
source§

fn invert_self(&mut self)

Invert this matrix in-place.
source§

fn is_invertible(&self) -> bool

Test if this matrix is invertible.
source§

fn is_one(&self) -> bool

Test if this matrix is the identity matrix. That is, it is diagonal and every element in the diagonal is one.
source§

impl<'a, 'b, S: BaseFloat> Sub<&'a Matrix4<S>> for &'b Matrix4<S>

§

type Output = Matrix4<S>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'a Matrix4<S>) -> Matrix4<S>

Performs the - operation. Read more
source§

impl<S: Copy> Copy for Matrix4<S>

source§

impl<S> StructuralPartialEq for Matrix4<S>

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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.