[][src]Trait gramit::mat::SquareMatrix

pub trait SquareMatrix: Copy {
    type VecType;

    const DIMS: usize;

    fn ones() -> Self;
fn zeros() -> Self;
fn identity() -> Self;
fn transpose(&self) -> Self;
fn determinant(&self) -> f32;
fn inverse(&self) -> Self;
fn minor(&self, col: usize, row: usize) -> f32;
fn cofactor(&self, col: usize, row: usize) -> f32;
fn get_col(&self, i: usize) -> Self::VecType;
fn get_row(&self, i: usize) -> Self::VecType;
fn set_col(&mut self, i: usize, c: Self::VecType);
fn set_row(&mut self, i: usize, r: Self::VecType); }

Associated Types

type VecType

The type used to represent the columns and rows of the matrix type.

Loading content...

Associated Constants

const DIMS: usize

The number of rows (or columns) of this matrix.

Loading content...

Required methods

fn ones() -> Self

Produce a matrix whose elements are all 1's.

fn zeros() -> Self

Produce a matrix whose elements are all 0's.

fn identity() -> Self

Produce an identity matrix, i.e. a matrix with 1's on the main diagonal and 0's elsewhere.

fn transpose(&self) -> Self

Get the transpose of this matrix.

fn determinant(&self) -> f32

Get the determinant of this matrix.

fn inverse(&self) -> Self

Get the inverse of this matrix.

fn minor(&self, col: usize, row: usize) -> f32

Get the row-col minor of this matrix.

This is the determinant of the matrix produced by omitting the row'th row and the col'th column of this matrix.

Panics

This function panics if either col or row is out of bounds of the matrix.

fn cofactor(&self, col: usize, row: usize) -> f32

Get the row-col cofactor of this matrix.

This is the row-col minor, multiplied by 1 or -1 depending on the parity of row+col.

Panics

This function panics if either col or row is out of bounds of the matrix.

fn get_col(&self, i: usize) -> Self::VecType

Get the i'th column of this matrix.

Panics

This function panics if i is out of bounds.

fn get_row(&self, i: usize) -> Self::VecType

Get the i'th row of this matrix.

Panics

This function panics if i is out of bounds.

fn set_col(&mut self, i: usize, c: Self::VecType)

Set the i'th column of this matrix to match the given vector.

Panics

This function panics if i is out of bounds.

fn set_row(&mut self, i: usize, r: Self::VecType)

Set the i'th row of this matrix to match the given vector.

Panics

This function panics if i is out of bounds.

Loading content...

Implementors

impl SquareMatrix for Mat2[src]

type VecType = Vec2

impl SquareMatrix for Mat3[src]

type VecType = Vec3

impl SquareMatrix for Mat4[src]

type VecType = Vec4

Loading content...