# [−][src]Struct cgmath::Matrix4

```#[repr(C)]
pub struct Matrix4<S> {
pub x: Vector4<S>,
pub y: Vector4<S>,
pub z: Vector4<S>,
pub w: Vector4<S>,
}```

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.

## Methods

### `impl<S> Matrix4<S>`[src]

#### `pub const 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>`[src]

Create a new matrix, providing values for each index.

#### `pub const fn from_cols(    c0: Vector4<S>,     c1: Vector4<S>,     c2: Vector4<S>,     c3: Vector4<S>) -> Matrix4<S>`[src]

Create a new matrix, providing columns.

### `impl<S: BaseFloat> Matrix4<S>`[src]

#### `pub fn from_translation(v: Vector3<S>) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a translation vector.

#### `pub fn from_scale(value: S) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a scale value.

#### `pub fn from_nonuniform_scale(x: S, y: S, z: S) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a set of scale values.

#### `pub fn look_at_dir(    eye: Point3<S>,     dir: Vector3<S>,     up: Vector3<S>) -> Matrix4<S>`[src]

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

#### `pub fn look_at(eye: Point3<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S>`[src]

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

#### `pub fn from_angle_x<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a rotation around the `x` axis (pitch).

#### `pub fn from_angle_y<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a rotation around the `y` axis (yaw).

#### `pub fn from_angle_z<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from a rotation around the `z` axis (roll).

#### `pub fn from_axis_angle<A: Into<Rad<S>>>(    axis: Vector3<S>,     angle: A) -> Matrix4<S>`[src]

Create a homogeneous transformation matrix from an angle around an arbitrary axis.

The specified axis must be normalized, or it represents an invalid rotation.

#### `pub fn is_finite(&self) -> bool`[src]

Are all entries in the matrix finite.

### `impl<S: NumCast + Copy> Matrix4<S>`[src]

#### `pub fn cast<T: NumCast>(&self) -> Option<Matrix4<T>>`[src]

Component-wise casting to another type

## Trait Implementations

### `impl<S: BaseFloat> VectorSpace for Matrix4<S>`[src]

#### `type Scalar = S`

The associated scalar.

#### `fn lerp(self, other: Self, amount: Self::Scalar) -> Self`[src]

Returns the result of linearly interpolating the vector towards `other` by the specified amount. Read more

### `impl<S: BaseFloat> Matrix for Matrix4<S>`[src]

#### `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 result of transposing the matrix

#### `fn as_ptr(&self) -> *const Self::Scalar`[src]

Get the pointer to the first element of the array.

#### `fn as_mut_ptr(&mut self) -> *mut Self::Scalar`[src]

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

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

Replace a column in the array.

### `impl<S: BaseFloat> SquareMatrix for Matrix4<S>`[src]

#### `type ColumnRow = Vector4<S>`

The row/column vector of the matrix. Read more

#### `fn identity() -> Self`[src]

The [identity matrix]. Multiplying this matrix with another should have no effect. Read more

#### `fn trace(&self) -> Self::Scalar`[src]

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

#### `fn is_invertible(&self) -> bool`[src]

Test if this matrix is invertible.

#### `fn is_identity(&self) -> bool`[src]

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

### `impl<S: BaseFloat> Transform<Point3<S>> for Matrix4<S>`[src]

#### `fn inverse_transform_vector(&self, vec: P::Diff) -> Option<P::Diff>`[src]

Inverse transform a vector using this transform

#### `fn concat_self(&mut self, other: &Self)`[src]

Combine this transform with another, in-place.

### `impl<S: BaseFloat> From<Matrix2<S>> for Matrix4<S>`[src]

#### `fn from(m: Matrix2<S>) -> Matrix4<S>`[src]

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

### `impl<S: BaseFloat> From<Matrix3<S>> for Matrix4<S>`[src]

#### `fn from(m: Matrix3<S>) -> Matrix4<S>`[src]

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

### `impl<S: BaseFloat> From<Quaternion<S>> for Matrix4<S>`[src]

#### `fn from(quat: Quaternion<S>) -> Matrix4<S>`[src]

Convert the quaternion to a 4 x 4 rotation matrix.

### `impl<S: Clone> Clone for Matrix4<S>`[src]

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl<S: BaseFloat> Add<Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `+` operator.

### `impl<'a, S: BaseFloat> Add<&'a Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `+` operator.

### `impl<'a, S: BaseFloat> Add<Matrix4<S>> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `+` operator.

### `impl<'a, 'b, S: BaseFloat> Add<&'a Matrix4<S>> for &'b Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `+` operator.

### `impl<S: BaseFloat> Sub<Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<'a, S: BaseFloat> Sub<&'a Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<'a, S: BaseFloat> Sub<Matrix4<S>> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<'a, 'b, S: BaseFloat> Sub<&'a Matrix4<S>> for &'b Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<S: BaseFloat> Mul<S> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, S: BaseFloat> Mul<S> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `*` operator.

### `impl Mul<Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `*` operator.

### `impl<'a> Mul<&'a Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `*` operator.

### `impl<S: BaseFloat> Mul<Vector4<S>> for Matrix4<S>`[src]

#### `type Output = Vector4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, S: BaseFloat> Mul<&'a Vector4<S>> for Matrix4<S>`[src]

#### `type Output = Vector4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, S: BaseFloat> Mul<Vector4<S>> for &'a Matrix4<S>`[src]

#### `type Output = Vector4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, 'b, S: BaseFloat> Mul<&'a Vector4<S>> for &'b Matrix4<S>`[src]

#### `type Output = Vector4<S>`

The resulting type after applying the `*` operator.

### `impl<S: BaseFloat> Mul<Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, S: BaseFloat> Mul<&'a Matrix4<S>> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, S: BaseFloat> Mul<Matrix4<S>> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl<'a, 'b, S: BaseFloat> Mul<&'a Matrix4<S>> for &'b Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `*` operator.

### `impl<S: BaseFloat> Div<S> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `/` operator.

### `impl<'a, S: BaseFloat> Div<S> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `/` operator.

### `impl Div<Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `/` operator.

### `impl<'a> Div<&'a Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `/` operator.

### `impl<S: BaseFloat> Rem<S> for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `%` operator.

### `impl<'a, S: BaseFloat> Rem<S> for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<usize>> for usize`[src]

#### `type Output = Matrix4<usize>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<u8>> for u8`[src]

#### `type Output = Matrix4<u8>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<u16>> for u16`[src]

#### `type Output = Matrix4<u16>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<u32>> for u32`[src]

#### `type Output = Matrix4<u32>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<u64>> for u64`[src]

#### `type Output = Matrix4<u64>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<isize>> for isize`[src]

#### `type Output = Matrix4<isize>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<i8>> for i8`[src]

#### `type Output = Matrix4<i8>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<i16>> for i16`[src]

#### `type Output = Matrix4<i16>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<i32>> for i32`[src]

#### `type Output = Matrix4<i32>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<i64>> for i64`[src]

#### `type Output = Matrix4<i64>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<f32>> for f32`[src]

#### `type Output = Matrix4<f32>`

The resulting type after applying the `%` operator.

### `impl Rem<Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `%` operator.

### `impl<'a> Rem<&'a Matrix4<f64>> for f64`[src]

#### `type Output = Matrix4<f64>`

The resulting type after applying the `%` operator.

### `impl<S: BaseFloat> Neg for Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<'a, S: BaseFloat> Neg for &'a Matrix4<S>`[src]

#### `type Output = Matrix4<S>`

The resulting type after applying the `-` operator.

### `impl<S> Index<usize> for Matrix4<S>`[src]

#### `type Output = Vector4<S>`

The returned type after indexing.

### `impl<S: BaseFloat> AbsDiffEq for Matrix4<S>`[src]

#### `type Epsilon = S::Epsilon`

Used for specifying relative comparisons.

#### `fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool`[src]

The inverse of `ApproxEq::abs_diff_eq`.

### `impl<S: BaseFloat> RelativeEq for Matrix4<S>`[src]

#### `fn relative_ne(    &self,     other: &Self,     epsilon: Self::Epsilon,     max_relative: Self::Epsilon) -> bool`[src]

The inverse of `ApproxEq::relative_eq`.

### `impl<S: BaseFloat> UlpsEq for Matrix4<S>`[src]

#### `fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool`[src]

The inverse of `ApproxEq::ulps_eq`.

### `impl<S: BaseFloat> One for Matrix4<S>`[src]

#### `fn is_one(&self) -> bool where    Self: PartialEq<Self>, `[src]

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

### `impl<S> Distribution<Matrix4<S>> for Standard where    Standard: Distribution<Vector4<S>>,    S: BaseFloat, `[src]

#### `fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where    R: Rng, `[src]

Create an iterator that generates random values of `T`, using `rng` as the source of randomness. Read more

## Blanket Implementations

### `impl<T, U> TryFrom for T where    T: From<U>, `[src]

#### `type Error = !`

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

The type returned in the event of a conversion error.

### `impl<T, U> TryInto for T where    U: TryFrom<T>, `[src]

#### `type Error = <U as TryFrom<T>>::Error`

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

The type returned in the event of a conversion error.