Struct cgmath::Matrix3

source ·
pub struct Matrix3<S> {
    pub x: Vector3<S>,
    pub y: Vector3<S>,
    pub z: Vector3<S>,
}
Expand description

A 3 x 3, column major matrix

Fields§

§x: Vector3<S>§y: Vector3<S>§z: Vector3<S>

Implementations§

source§

impl<S> Matrix3<S>

source

pub fn new( c0r0: S, c0r1: S, c0r2: S, c1r0: S, c1r1: S, c1r2: S, c2r0: S, c2r1: S, c2r2: S ) -> Matrix3<S>

Create a new matrix, providing values for each index.

source

pub fn from_cols(c0: Vector3<S>, c1: Vector3<S>, c2: Vector3<S>) -> Matrix3<S>

Create a new matrix, providing columns.

source§

impl<S: BaseFloat> Matrix3<S>

source

pub fn look_at(dir: Vector3<S>, up: Vector3<S>) -> Matrix3<S>

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

source

pub fn from_angle_x(theta: Rad<S>) -> Matrix3<S>

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

source

pub fn from_angle_y(theta: Rad<S>) -> Matrix3<S>

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

source

pub fn from_angle_z(theta: Rad<S>) -> Matrix3<S>

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

source

pub fn from_euler(x: Rad<S>, y: Rad<S>, z: Rad<S>) -> Matrix3<S>

Create a matrix from a set of euler angles.

Parameters
  • x: the angular rotation around the x axis (pitch).
  • y: the angular rotation around the y axis (yaw).
  • z: the angular rotation around the z axis (roll).
source

pub fn from_axis_angle(axis: Vector3<S>, angle: Rad<S>) -> Matrix3<S>

Create a matrix from a rotation around an arbitrary axis

source§

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

source

pub fn neg_self(&mut self)

Negate this Matrix3 in-place.

Trait Implementations§

source§

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

§

type Output = Matrix3<S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

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

§

type Epsilon = S

source§

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

source§

fn approx_epsilon() -> Self::Epsilon

source§

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

source§

impl<S> AsMut<[[S; 3]; 3]> for Matrix3<S>

source§

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

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

impl<S> AsMut<[S; 9]> for Matrix3<S>

source§

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

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

impl<S> AsRef<[[S; 3]; 3]> for Matrix3<S>

source§

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

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

impl<S> AsRef<[S; 9]> for Matrix3<S>

source§

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

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

impl<S> AsRef<Matrix3<S>> for Basis3<S>

source§

fn as_ref(&self) -> &Matrix3<S>

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

impl<S: Clone> Clone for Matrix3<S>

source§

fn clone(&self) -> Matrix3<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 Matrix3<S>

source§

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

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

impl<S: Decodable> Decodable for Matrix3<S>

source§

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

Deserialize a value using a Decoder.
source§

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

§

type Output = Matrix3<S>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<S: Encodable> Encodable for Matrix3<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; 3]; 3]> for &'a Matrix3<S>

source§

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

Converts to this type from the input type.
source§

impl<'a, S> From<&'a [S; 9]> for &'a Matrix3<S>

source§

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

Converts to this type from the input type.
source§

impl<'a, S> From<&'a mut [[S; 3]; 3]> for &'a mut Matrix3<S>

source§

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

Converts to this type from the input type.
source§

impl<'a, S> From<&'a mut [S; 9]> for &'a mut Matrix3<S>

source§

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

Converts to this type from the input type.
source§

impl<S: Copy> From<[[S; 3]; 3]> for Matrix3<S>

source§

fn from(m: [[S; 3]; 3]) -> Matrix3<S>

Converts to this type from the input type.
source§

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

source§

fn from(b: Basis3<S>) -> Matrix3<S>

Converts to this type from the input type.
source§

impl<S: BaseFloat, R: Rotation2<S>> From<Decomposed<Vector2<S>, R>> for Matrix3<S>

source§

fn from(dec: Decomposed<Vector2<S>, R>) -> Matrix3<S>

Converts to this type from the input type.
source§

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

source§

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

Clone the elements of a 2-dimensional matrix into the top-left corner of a 3-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<Matrix3<S>> for Quaternion<S>

source§

fn from(mat: Matrix3<S>) -> Quaternion<S>

Convert the matrix to a quaternion

source§

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

source§

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

Convert the quaternion to a 3 x 3 rotation matrix

source§

impl<S> Index<usize> for Matrix3<S>

§

type Output = Vector3<S>

The returned type after indexing.
source§

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

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

impl<S> IndexMut<usize> for Matrix3<S>

source§

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

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

impl<S> Into<[[S; 3]; 3]> for Matrix3<S>

source§

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

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

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

§

type Element = S

The type of the elements in the matrix.
§

type Column = Vector3<S>

The column vector of the matrix.
§

type Row = Vector3<S>

The row vector of the matrix.
§

type Transpose = Matrix3<S>

The type of the transposed matrix
source§

fn row(&self, r: usize) -> Vector3<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() -> Matrix3<S>

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

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

Multiply the matrix by another matrix,
source§

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

Multiply the matrix by a column vector.
source§

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

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

fn div_s(&self, s: S) -> Matrix3<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) -> Matrix3<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 Matrix3<S>> for &'b Matrix3<S>

§

type Output = Matrix3<S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Vector3<S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Matrix3<S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Vector3<S>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Matrix3<S>

The resulting type after applying the - operator.
source§

fn neg(self) -> Matrix3<S>

Performs the unary - operation. Read more
source§

impl<S: PartialEq> PartialEq<Matrix3<S>> for Matrix3<S>

source§

fn eq(&self, other: &Matrix3<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 Matrix3<S>

source§

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

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

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

§

type Output = Matrix3<S>

The resulting type after applying the % operator.
source§

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

Performs the % operation. Read more
source§

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

§

type ColumnRow = Vector3<S>

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

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

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

fn from_diagonal(value: Vector3<S>) -> Matrix3<S>

Create a matrix from a non-uniform scale
source§

fn one() -> Matrix3<S>

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

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

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

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

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

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

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

fn sub_self_m(&mut self, m: &Matrix3<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) -> Vector3<S>

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

fn invert(&self) -> Option<Matrix3<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 Matrix3<S>> for &'b Matrix3<S>

§

type Output = Matrix3<S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<S: Copy> Copy for Matrix3<S>

source§

impl<S> StructuralPartialEq for Matrix3<S>

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Matrix3<S>where S: RefUnwindSafe,

§

impl<S> Send for Matrix3<S>where S: Send,

§

impl<S> Sync for Matrix3<S>where S: Sync,

§

impl<S> Unpin for Matrix3<S>where S: Unpin,

§

impl<S> UnwindSafe for Matrix3<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.