pub trait Matrix {
type MatrixType;
type VectorType;
Show 16 methods
// Required methods
fn zeros() -> Self::MatrixType;
fn ones() -> Self::MatrixType;
fn identity() -> Self::MatrixType;
fn copy_to(&self, dst: &mut Self::MatrixType);
fn transpose(&mut self) -> &mut Self::MatrixType;
fn mul(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType;
fn mul_vector(&self, rhs: &[f32]) -> Self::VectorType;
fn mul_vector_left(&self, lhs: &[f32]) -> Self::VectorType;
fn add(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType;
fn sub(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType;
fn scale(&mut self, factor: f32) -> &mut Self::MatrixType;
fn inverse(&mut self) -> Option<&mut Self::MatrixType>;
fn det(&self) -> f32;
fn adjugate(&mut self) -> &mut Self::MatrixType;
fn translate(&mut self, direction: &[f32]) -> &mut Self::MatrixType;
fn rotate(&mut self, angle: f32, axis: &[f32]) -> &mut Self::MatrixType;
}
Expand description
The base Matrix trait
Required Associated Types§
type MatrixType
type VectorType
Required Methods§
Sourcefn zeros() -> Self::MatrixType
fn zeros() -> Self::MatrixType
Create a matrix filled with zeros
Sourcefn ones() -> Self::MatrixType
fn ones() -> Self::MatrixType
Create a matrix filled with ones
Sourcefn identity() -> Self::MatrixType
fn identity() -> Self::MatrixType
Create the identity matrix
Sourcefn copy_to(&self, dst: &mut Self::MatrixType)
fn copy_to(&self, dst: &mut Self::MatrixType)
Copy values to another matrix
Sourcefn transpose(&mut self) -> &mut Self::MatrixType
fn transpose(&mut self) -> &mut Self::MatrixType
Compute the transpose of this matrix
Sourcefn mul(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
fn mul(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
Perform matrix-multiplication with the given right-hand-side operand
Sourcefn mul_vector(&self, rhs: &[f32]) -> Self::VectorType
fn mul_vector(&self, rhs: &[f32]) -> Self::VectorType
Multiplies this matrix with the given right-hand-side vector, i.e. Matrix * rhs
Depending on dimensionality, the homogenous coordinate can be omitted, if so, it will be assumed to be equal to 1.
Sourcefn mul_vector_left(&self, lhs: &[f32]) -> Self::VectorType
fn mul_vector_left(&self, lhs: &[f32]) -> Self::VectorType
Multiplies the given row vector with this matrix, i.e. lhs * Matrix
Depending on dimensionality, the homogenous coordinate can be omitted, if so, it will be assumed to be equal to 1.
Sourcefn add(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
fn add(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
Perform element-wise addition with the given right-hand-side operand
Sourcefn sub(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
fn sub(&mut self, rhs: &Self::MatrixType) -> &mut Self::MatrixType
Perform element-wise substraction with the given right-hand-side operand
Sourcefn scale(&mut self, factor: f32) -> &mut Self::MatrixType
fn scale(&mut self, factor: f32) -> &mut Self::MatrixType
Scale the matrix elment-wise by the given constant
Sourcefn inverse(&mut self) -> Option<&mut Self::MatrixType>
fn inverse(&mut self) -> Option<&mut Self::MatrixType>
Compute the inverse of this matrix. Returns None
if it is singular.
Sourcefn adjugate(&mut self) -> &mut Self::MatrixType
fn adjugate(&mut self) -> &mut Self::MatrixType
Compute the adjugate of this matrix
Sourcefn translate(&mut self, direction: &[f32]) -> &mut Self::MatrixType
fn translate(&mut self, direction: &[f32]) -> &mut Self::MatrixType
Translate this matrix into the given direction
Depending on dimensionality, the homogenous coordinate of direction
can be omitted,
if so, it will be assumed to be equal to 1.
Sourcefn rotate(&mut self, angle: f32, axis: &[f32]) -> &mut Self::MatrixType
fn rotate(&mut self, angle: f32, axis: &[f32]) -> &mut Self::MatrixType
Rotate this matrix by the given angle (radians) around the given axis
Depending on dimensionality, the homogenous coordinate of axis
can be omitted,
if so, it will be assumed to be equal to 1.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.