Skip to main content

Matrix3

Struct Matrix3 

Source
pub struct Matrix3<T> { /* private fields */ }
Expand description

A 3×3 matrix stored as three column vectors.

Implementations§

Source§

impl<T> Matrix3<T>

Source

pub const fn from_cols( x_col: Vector3<T>, y_col: Vector3<T>, z_col: Vector3<T>, ) -> Self

Constructs a matrix from its three column vectors.

Source

pub fn map<U, F: FnMut(T) -> U>(self, f: F) -> Matrix3<U>

Applies f to every element in column-major order, returning the resulting matrix.

Source

pub fn zip_map<U, R, F: FnMut(T, U) -> R>( self, rhs: Matrix3<U>, f: F, ) -> Matrix3<R>

Combines self and rhs element-wise in column-major order through f.

Source§

impl<T: Copy> Matrix3<T>

Source

pub fn from_rows( x_row: Vector3<T>, y_row: Vector3<T>, z_row: Vector3<T>, ) -> Self

Constructs a matrix from its three row vectors.

Source

pub fn from_cols_array(m: &[T; 9]) -> Self

Constructs a matrix from a column-major array of nine elements.

Source

pub fn to_cols_array(&self) -> [T; 9]

Returns the elements as a column-major array of nine elements.

Source

pub fn col(&self, index: usize) -> Vector3<T>

Returns the column at index.

§Panics

Panics if index is greater than 2.

Source

pub fn row(&self, index: usize) -> Vector3<T>

Returns the row at index.

§Panics

Panics if index is greater than 2.

Source

pub fn transpose(&self) -> Self

Returns the transpose, exchanging rows and columns.

Source§

impl<T: Copy + Default> Matrix3<T>

Source

pub fn from_diagonal(diagonal: Vector3<T>) -> Self

Constructs a diagonal matrix whose diagonal is diagonal and whose off-diagonal elements are the default (zero) value of T.

Source

pub fn diagonal(&self) -> Vector3<T>

Returns the main diagonal as a vector.

Source§

impl<V: Scalar> Matrix3<V>

Source

pub const ZERO: Self

The zero matrix.

Source

pub const IDENTITY: Self

The identity matrix.

Source

pub fn from_scale(scale: Vector3<V>) -> Self

Constructs a non-uniform scaling matrix from the per-axis factors in scale.

Source

pub fn outer_product(a: Vector3<V>, b: Vector3<V>) -> Self

Constructs the outer (dyadic) product a ⊗ b, the 3×3 matrix whose (i, j) entry is aᵢ · bⱼ.

Source

pub fn from_rotation_x(angle: V) -> Self

Constructs a right-handed rotation of angle radians about the x axis.

Source

pub fn from_rotation_y(angle: V) -> Self

Constructs a right-handed rotation of angle radians about the y axis.

Source

pub fn from_rotation_z(angle: V) -> Self

Constructs a right-handed rotation of angle radians about the z axis.

Source

pub fn from_axis_angle(axis: Vector3<V>, angle: V) -> Self

Constructs a right-handed rotation of angle radians about the unit vector axis (Rodrigues’ rotation formula).

axis is assumed to be normalized; a non-unit axis yields a matrix that also scales.

Source

pub fn trace(&self) -> V

Returns the trace, the sum of the diagonal elements.

Source

pub fn determinant(&self) -> V

Returns the determinant.

Source

pub fn is_invertible(&self) -> bool

Returns true if the matrix has a finite, non-zero determinant and is therefore invertible.

Source

pub fn try_inverse(&self) -> Option<Self>

Returns the inverse, or None if the matrix is not invertible.

Source

pub fn inverse(&self) -> Self

Returns the inverse.

§Panics

Panics if the matrix is not invertible; use try_inverse to handle singular matrices.

Trait Implementations§

Source§

impl<T: Add<Output = T>> Add for Matrix3<T>

Source§

fn add(self, rhs: Self) -> Self

Returns the component-wise sum of self and rhs.

Source§

type Output = Matrix3<T>

The resulting type after applying the + operator.
Source§

impl<T: AddAssign> AddAssign for Matrix3<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Matrix3<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for Matrix3<T>

Source§

impl<T: Debug> Debug for Matrix3<T>

Source§

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

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

impl<T: Default> Default for Matrix3<T>

Source§

fn default() -> Self

Returns the zero matrix.

Source§

impl<T: Div<S, Output = T> + Copy, S: Scalar> Div<S> for Matrix3<T>

Source§

fn div(self, rhs: S) -> Self

Divides every element by the scalar rhs.

Source§

type Output = Matrix3<T>

The resulting type after applying the / operator.
Source§

impl<T: DivAssign<S> + Copy, S: Scalar> DivAssign<S> for Matrix3<T>

Source§

fn div_assign(&mut self, rhs: S)

Performs the /= operation. Read more
Source§

impl<V: Scalar> Mul for Matrix3<V>

Source§

fn mul(self, rhs: Self) -> Self

Returns the matrix product self * rhs.

Source§

type Output = Matrix3<V>

The resulting type after applying the * operator.
Source§

impl<T: Mul<S, Output = T> + Copy, S: Scalar> Mul<S> for Matrix3<T>

Source§

fn mul(self, rhs: S) -> Self

Scales every element by the scalar rhs.

Source§

type Output = Matrix3<T>

The resulting type after applying the * operator.
Source§

impl<V: Scalar> Mul<Vector3<V>> for Matrix3<V>

Source§

fn mul(self, rhs: Vector3<V>) -> Vector3<V>

Applies the matrix to the vector, returning self * rhs.

Source§

type Output = Vector3<V>

The resulting type after applying the * operator.
Source§

impl<V: Scalar> MulAssign for Matrix3<V>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T: MulAssign<S> + Copy, S: Scalar> MulAssign<S> for Matrix3<T>

Source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
Source§

impl<T: Neg<Output = T>> Neg for Matrix3<T>

Source§

fn neg(self) -> Self

Returns the component-wise negation of self.

Source§

type Output = Matrix3<T>

The resulting type after applying the - operator.
Source§

impl<T: PartialEq> PartialEq for Matrix3<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Sub<Output = T>> Sub for Matrix3<T>

Source§

fn sub(self, rhs: Self) -> Self

Returns the component-wise difference of self and rhs.

Source§

type Output = Matrix3<T>

The resulting type after applying the - operator.
Source§

impl<T: SubAssign> SubAssign for Matrix3<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Matrix3<T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for Matrix3<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Matrix3<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.