Struct cgl_rs::math::Matrix3x3

source ·
#[repr(C)]
pub struct Matrix3x3 { /* private fields */ }
Expand description

A 3x3 matrix struct used for graphics programming with OpenGL.

Implementations§

source§

impl Matrix3x3

source

pub fn new( m0: f32, m1: f32, m2: f32, m3: f32, m4: f32, m5: f32, m6: f32, m7: f32, m8: f32 ) -> Matrix3x3

Creates a new 3x3 matrix.

Arguments

m0 … m8: The values of the matrix.

Returns

A new 3x3 matrix.

Example
use cgl_rs::math::Matrix3x3;
 
let m = Matrix3x3::new(
   1.0, 0.0, 0.0,
   0.0, 1.0, 0.0,
   0.0, 0.0, 1.0
);
source

pub fn zero() -> Matrix3x3

Creates a new 3x3 matrix with all elements set to zero.

Returns

A new 3x3 matrix with all elements set to zero.

Example
use cgl_rs::math::Matrix3x3;

let m = Matrix3x3::zero();
source

pub fn identity() -> Matrix3x3

Creates a new 3x3 identity matrix.

Returns

A new 3x3 identity matrix.

Example
use cgl_rs::math::Matrix3x3;

let m = Matrix3x3::identity();
source

pub fn transpose(&self) -> Matrix3x3

Transposes the matrix.

Returns

A new 3x3 matrix that is the transpose of the original matrix.

Example
use cgl_rs::math::Matrix3x3;

let m = Matrix3x3::new(
    1.0, 2.0, 3.0,
    4.0, 5.0, 6.0,
    7.0, 8.0, 9.0
);

let m_transpose = m.transpose();
source

pub fn trace(&self) -> f32

Calculates the trace of the matrix.

Returns

The sum of the diagonal elements of the matrix.

Example
use cgl_rs::math::Matrix3x3;

let m = Matrix3x3::new(
    1.0, 2.0, 3.0,
    4.0, 5.0, 6.0,
    7.0, 8.0, 9.0
);

let trace = m.trace();
source

pub fn determinant(&self) -> f32

Calculates the determinant of the matrix.

Returns

The determinant of the matrix.

Example
use cgl_rs::math::Matrix3x3;

let m = Matrix3x3::new(
    1.0, 2.0, 3.0,
    4.0, 5.0, 6.0,
    7.0, 8.0, 9.0
);

let det = m.determinant();

Trait Implementations§

source§

impl Add<Matrix3x3> for Matrix3x3

§

type Output = Matrix3x3

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Clone for Matrix3x3

source§

fn clone(&self) -> Matrix3x3

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 Debug for Matrix3x3

source§

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

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

impl Display for Matrix3x3

source§

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

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

impl Mul<f32> for Matrix3x3

§

type Output = Matrix3x3

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Matrix3x3

Performs the * operation. Read more
source§

impl PartialEq<Matrix3x3> for Matrix3x3

source§

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

§

type Output = Matrix3x3

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Copy for Matrix3x3

source§

impl StructuralPartialEq for Matrix3x3

Auto Trait Implementations§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.