Skip to main content

Matrix3

Struct Matrix3 

Source
pub struct Matrix3 {
    pub rows: [[f64; 3]; 3],
}
Expand description

A 3×3 matrix, row-major.

Fields§

§rows: [[f64; 3]; 3]

Rows, each [m[i][0], m[i][1], m[i][2]].

Implementations§

Source§

impl Matrix3

Source

pub const IDENTITY: Self

The identity.

Source

pub const ZERO: Self

All zeros.

Source

pub const fn new(rows: [[f64; 3]; 3]) -> Self

From rows.

Source

pub const fn from_columns(a: Vector, b: Vector, c: Vector) -> Self

From column vectors.

Source

pub const fn from_rows(a: Vector, b: Vector, c: Vector) -> Self

From row vectors.

Source

pub const fn scaling(s: f64) -> Self

A uniform scaling.

Source

pub const fn scaling_xyz(x: f64, y: f64, z: f64) -> Self

A non-uniform scaling along the coordinate axes.

Source

pub fn rotation(axis: Direction, angle: f64) -> Self

A right-handed rotation of angle radians about axis.

Rodrigues’ formula. Orthonormal to within rounding for any unit axis, which Direction guarantees.

Source

pub fn reflection(n: Direction) -> Self

Reflection in the plane through the origin with normal n.

Source

pub fn get(&self, row: usize, col: usize) -> OgeomResult<f64>

Element at (row, col).

§Errors

OgeomError::Range if either index exceeds 2.

Source

pub fn column(&self, i: usize) -> OgeomResult<Vector>

Column i as a vector.

§Errors

OgeomError::Range if i > 2.

Source

pub fn row(&self, i: usize) -> OgeomResult<Vector>

Row i as a vector.

§Errors

OgeomError::Range if i > 2.

Source

pub const fn transposed(&self) -> Self

The transpose.

Source

pub fn determinant(&self) -> f64

The determinant.

Source

pub fn trace(&self) -> f64

The trace.

Source

pub fn inverse(&self) -> OgeomResult<Self>

The inverse.

§Errors

OgeomError::Numeric if the matrix is singular.

Singularity is a question of numerical conditioning, not of modelling tolerance, so this takes no Tolerances. The determinant is compared against the rounding error incurred computing it: for an n x n matrix with entries bounded by s, that is on the order of n * n! * eps * s^n. The bound scales with the entries and has no absolute floor, because a matrix scaled by 1e-3 has a determinant scaled by 1e-9 and is no less invertible for it.

Source

pub fn is_orthonormal(&self, eps: f64) -> bool

Whether the matrix is orthonormal: its rows form an orthonormal basis, so it represents a rotation or a reflection and its inverse is its transpose.

Source

pub fn is_equal(&self, other: &Self, eps: f64) -> bool

Whether every element agrees with other within eps.

Takes a bare epsilon rather than Tolerances: matrix entries are dimensionless ratios, and a length tolerance does not apply to them.

Source

pub fn is_finite(&self) -> bool

Whether every element is finite.

Trait Implementations§

Source§

impl Add for Matrix3

Source§

type Output = Matrix3

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for Matrix3

Source§

fn clone(&self) -> Matrix3

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 Copy for Matrix3

Source§

impl Debug for Matrix3

Source§

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

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

impl Default for Matrix3

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Mul for Matrix3

Source§

type Output = Matrix3

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vector> for Matrix3

Source§

type Output = Vector

The resulting type after applying the * operator.
Source§

fn mul(self, v: Vector) -> Vector

Performs the * operation. Read more
Source§

impl Mul<f64> for Matrix3

Source§

type Output = Matrix3

The resulting type after applying the * operator.
Source§

fn mul(self, s: f64) -> Self

Performs the * operation. Read more
Source§

impl Neg for Matrix3

Source§

type Output = Matrix3

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Matrix3

Source§

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

Source§

impl Sub for Matrix3

Source§

type Output = Matrix3

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

Auto Trait Implementations§

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
§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.