Struct cgmath::Matrix4 [−] [src]

```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, packed)]`.

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: BaseFloat> Matrix4<S>`[src]

`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.

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

Create a new matrix, providing columns.

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

Create a homogeneous transformation matrix from a translation vector.

`fn from_scale(value: S) -> Matrix4<S>`

Create a homogeneous transformation matrix from a scale value.

`fn from_nonuniform_scale(x: S, y: S, z: S) -> Matrix4<S>`

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

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

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

`fn from_angle_x<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`

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

`fn from_angle_y<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`

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

`fn from_angle_z<A: Into<Rad<S>>>(theta: A) -> Matrix4<S>`

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

`fn from_axis_angle<A: Into<Rad<S>>>(axis: Vector3<S>, angle: A) -> Matrix4<S>`

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

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

Trait Implementations

`impl<S: PartialEq> PartialEq for Matrix4<S>`[src]

`fn eq(&self, __arg_0: &Matrix4<S>) -> bool`

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

`fn ne(&self, __arg_0: &Matrix4<S>) -> bool`

This method tests for `!=`.

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

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

Returns a copy of the value. Read more

`fn clone_from(&mut self, source: &Self)`1.0.0

Performs copy-assignment from `source`. Read more

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

`fn zero() -> Matrix4<S>`

Returns the additive identity element of `Self`, `0`. Read more

`fn is_zero(&self) -> bool`

Returns `true` if `self` is equal to the additive identity.

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

`fn one() -> Matrix4<S>`

Returns the multiplicative identity element of `Self`, `1`. Read more

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

`type Scalar = S`

The associated scalar.

`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 row(&self, r: usize) -> Vector4<S>`

Get a row from this matrix by-value.

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

Swap two rows of this array.

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

Swap two columns of this array.

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

Swap the values at index `a` and `b`

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

Transpose this matrix, returning a new matrix.

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

Get the pointer to the first element of the array.

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

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

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

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 from_value(value: S) -> Matrix4<S>`

Create a new diagonal matrix using the supplied value.

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

Create a matrix from a non-uniform scale

`fn transpose_self(&mut self)`

Transpose this matrix in-place.

`fn determinant(&self) -> S`

Take the determinant of this matrix.

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

Return a vector containing the diagonal of this matrix.

`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

`fn is_diagonal(&self) -> bool`

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

`fn is_symmetric(&self) -> bool`

Test if this matrix is symmetric. That is, it is equal to its transpose. Read more

`fn identity() -> Self`

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

`fn trace(&self) -> Self::Scalar`

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

`fn is_invertible(&self) -> bool`

Test if this matrix is invertible.

`fn is_identity(&self) -> bool`

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 one() -> Matrix4<S>`

Create an identity transformation. That is, a transformation which does nothing. Read more

`fn look_at(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

`fn transform_vector(&self, vec: Vector3<S>) -> Vector3<S>`

Transform a vector using this transform.

`fn transform_point(&self, point: Point3<S>) -> Point3<S>`

Transform a point using this transform.

`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

`fn inverse_transform(&self) -> Option<Matrix4<S>>`

Create a transform that "un-does" this one.

`fn concat_self(&mut self, other: &Self)`

Combine this transform with another, in-place.

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

`type Output = Matrix4<S>`

The resulting type after applying the `-` operator

`fn neg(self) -> Matrix4<S>`

The method for the unary `-` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `-` operator

`fn neg(self) -> Matrix4<S>`

The method for the unary `-` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `*` operator

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

The method for the `*` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `*` operator

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

The method for the `*` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `/` operator

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

The method for the `/` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `/` operator

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

The method for the `/` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `%` operator

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

The method for the `%` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `%` operator

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

The method for the `%` operator

`impl<S: BaseFloat + MulAssign<S>> MulAssign<S> for Matrix4<S>`[src]

`fn mul_assign(&mut self, scalar: S)`

The method for the `*=` operator

`impl<S: BaseFloat + DivAssign<S>> DivAssign<S> for Matrix4<S>`[src]

`fn div_assign(&mut self, scalar: S)`

The method for the `/=` operator

`impl<S: BaseFloat + RemAssign<S>> RemAssign<S> for Matrix4<S>`[src]

`fn rem_assign(&mut self, scalar: S)`

The method for the `%=` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `+` operator

`fn add(self, other: Matrix4<S>) -> Matrix4<S>`

The method for 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

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

The method for 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

`fn add(self, other: Matrix4<S>) -> Matrix4<S>`

The method for 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

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

The method for the `+` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `-` operator

`fn sub(self, other: Matrix4<S>) -> Matrix4<S>`

The method for 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

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

The method for 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

`fn sub(self, other: Matrix4<S>) -> Matrix4<S>`

The method for 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

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

The method for the `-` operator

`impl<S: BaseFloat + AddAssign<S>> AddAssign<Matrix4<S>> for Matrix4<S>`[src]

`fn add_assign(&mut self, other: Matrix4<S>)`

The method for the `+=` operator

`impl<S: BaseFloat + SubAssign<S>> SubAssign<Matrix4<S>> for Matrix4<S>`[src]

`fn sub_assign(&mut self, other: Matrix4<S>)`

The method for the `-=` operator

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

`type Output = Vector4<S>`

The resulting type after applying the `*` operator

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

The method for 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

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

The method for 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

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

The method for 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

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

The method for the `*` operator

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

`type Output = Matrix4<S>`

The resulting type after applying the `*` operator

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

The method for 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

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

The method for 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

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

The method for 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

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

The method for the `*` operator

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

`type Output = Vector4<S>`

The returned type after indexing

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

The method for the indexing (`Foo[Bar]`) operation

`impl<S> IndexMut<usize> for Matrix4<S>`[src]

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

The method for the indexing (`Foo[Bar]`) operation

`impl<A> From<Euler<A>> for Matrix4<A::Unitless> where A: Angle + Into<Rad<A::Unitless>>`[src]

`fn from(src: Euler<A>) -> Matrix4<A::Unitless>`

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

`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.

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

`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.

`impl<S: Debug> Debug for Matrix4<S>`[src]

`fn fmt(&self, f: &mut Formatter) -> Result`

Formats the value using the given formatter.

`impl<S: BaseFloat + Rand> Rand for Matrix4<S>`[src]

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

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

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

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

Convert the quaternion to a 4 x 4 rotation matrix

`impl<S: BaseFloat, R: Rotation3<S>> From<Decomposed<Vector3<S>, R>> for Matrix4<S>`[src]

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.

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

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

Performs the conversion.