[][src]Struct hektor::Mat2

#[repr(C)]
pub struct Mat2 { /* fields omitted */ }

A 2x2 column-major Matrix.

There's two columns, and each column is itself a Vec2.

Methods

impl Mat2[src]

pub fn x_axis(self) -> Vec2[src]

Obtains the x_axis column of this matrix

pub fn y_axis(self) -> Vec2[src]

Obtains the y_axis column of this matrix

pub fn x_axis_mut(&mut self) -> &mut Vec2[src]

&mut to the x_axis column of this matrix

pub fn y_axis_mut(&mut self) -> &mut Vec2[src]

&mut to the y_axis column of this matrix

impl Mat2[src]

pub fn new(x_axis: Vec2, y_axis: Vec2) -> Self[src]

Combines the columns given into a new Mat2

pub fn splat(v: f32) -> Self[src]

Splats the given value across all columns.

pub fn diagonal(x: f32, y: f32) -> Self[src]

Forms a diagonal matrix from the values given.

pub fn to_mat3(self, z: f32) -> Mat3[src]

Up-converts to a Mat3 by adding the given z as the z of the z_axis. The x_axis and y_axis are extended with 0.0

pub fn determinant(self) -> f32[src]

Determinant of the matrix.

This gives the scale factor of a unit square in the matrix's modified coordinate space:

  • Positive means that the output orientation is generally similar.
  • Negative means that the output orientation is flipped.
  • Zero means that the output loses at least 1 dimension (meaning that squares become lines, or points).

pub fn transpose(self) -> Self[src]

Transpose the matrix.

This "flips" it along the diagonal. The diagonal values stay the same.

pub fn inverse(self) -> Option<Self>[src]

Gives the inverse matrix, if it exists.

m * m.inverse() and m.inverse() * m should both give an identity matrix as the output. As we all known, with floating point there's usually a little bit of rounding error possible so it may not work perfectly.

Failure

There's no inverse if the determinant is zero.

Trait Implementations

impl CanDeterminant for Mat2[src]

impl Display for Mat2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Display formats without labels in a 2 line style similar to standard math notation.

Passes the formatter along to the fields, so you can use any normal f32 Display format arguments that you like.

impl Debug for Mat2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Debug formats with each axis labeled and then shown as a 2-tuple in one long line.

Passes the formatter along to the fields, so you can use any normal f32 Debug format arguments that you like.

impl UpperExp for Mat2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

UpperExp formats like Display, but with the upper exponent.

Passes the formatter along to the fields, so you can use any normal f32 UpperExp format arguments that you like.

impl LowerExp for Mat2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

LowerExp formats like Display, but with the lower exponent.

Passes the formatter along to the fields, so you can use any normal f32 LowerExp format arguments that you like.

impl PartialEq<Mat2> for Mat2[src]

impl Add<Mat2> for Mat2[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<f32> for Mat2[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Mat2> for f32[src]

type Output = Mat2

The resulting type after applying the + operator.

impl Sub<Mat2> for Mat2[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<f32> for Mat2[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<Mat2> for f32[src]

type Output = Mat2

The resulting type after applying the - operator.

impl Mul<f32> for Mat2[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Mat2> for f32[src]

type Output = Mat2

The resulting type after applying the * operator.

impl Mul<Vec2> for Mat2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl Mul<Mat2> for Mat2[src]

type Output = Self

The resulting type after applying the * operator.

impl Neg for Mat2[src]

type Output = Self

The resulting type after applying the - operator.

impl AddAssign<Mat2> for Mat2[src]

impl AddAssign<f32> for Mat2[src]

impl SubAssign<Mat2> for Mat2[src]

impl SubAssign<f32> for Mat2[src]

impl MulAssign<f32> for Mat2[src]

impl MulAssign<Mat2> for Mat2[src]

impl Index<usize> for Mat2[src]

type Output = Vec2

The returned type after indexing.

impl IndexMut<usize> for Mat2[src]

impl Copy for Mat2[src]

impl AsRef<[Vec2; 2]> for Mat2[src]

impl AsMut<[Vec2; 2]> for Mat2[src]

impl From<[f32; 4]> for Mat2[src]

impl From<Mat2> for [f32; 4][src]

impl Clone for Mat2[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Mat2[src]

impl Pod for Mat2[src]

impl Zeroable for Mat2[src]

fn zeroed() -> Self[src]

Calls zeroed. Read more

Auto Trait Implementations

impl Unpin for Mat2

impl Sync for Mat2

impl Send for Mat2

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]