[][src]Struct physics2d::Mat2

pub struct Mat2 {
    pub a00: f32,
    pub a01: f32,
    pub a10: f32,
    pub a11: f32,
}

A square matrix of order 2.

It is primarily used to represent 2D rotation matrices, but can be used otherwise too.

The elements are named based on their zero-based row-column positions.

Fields

a00: f32

The element of the 1st row and 1st column.

a01: f32

The element of the 1st row and 2nd column.

a10: f32

The element of the 2nd row and 1st column.

a11: f32

The element of the 2nd row and 2nd column.

Methods

impl Mat2[src]

pub fn new(a00: f32, a01: f32, a10: f32, a11: f32) -> Mat2[src]

Creates a new matrix from the given elements.

pub fn rotation(angle: f32) -> Mat2[src]

Creates a new rotation matrix for a rotation angle in radians.

Examples


let a = Mat2::rotation(0.0);
let b = Mat2::new(1.0, 0.0,
                  0.0, 1.0);

assert_eq!(a, b);

pub fn transpose(&self) -> Mat2[src]

Returns the transpose of the matrix.

Examples


let a = Mat2::new(3.0, 1.0,
                  8.0, 1.0);
let a_t = Mat2::new(3.0, 8.0,
                    1.0, 1.0);

assert_eq!(a_t, a.transpose());

pub const I: Mat2[src]

Trait Implementations

impl Clone for Mat2[src]

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

Performs copy-assignment from source. Read more

impl PartialEq<Mat2> for Mat2[src]

impl Copy for Mat2[src]

impl Debug for Mat2[src]

impl Mul<Mat2> for Mat2[src]

type Output = Mat2

The resulting type after applying the * operator.

impl<'a> Mul<Mat2> for &'a Mat2[src]

type Output = Mat2

The resulting type after applying the * operator.

impl<'b> Mul<&'b Mat2> for Mat2[src]

type Output = Mat2

The resulting type after applying the * operator.

impl<'a, 'b> Mul<&'b Mat2> for &'a Mat2[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<'a> Mul<Vec2> for &'a Mat2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl<'b> Mul<&'b Vec2> for Mat2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl<'a, 'b> Mul<&'b Vec2> for &'a Mat2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl MulAssign<Mat2> for Mat2[src]

impl<'b> MulAssign<&'b Mat2> for Mat2[src]

Auto Trait Implementations

impl Sync for Mat2

impl Send for Mat2

impl Unpin for Mat2

impl RefUnwindSafe for Mat2

impl UnwindSafe for Mat2

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

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

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> 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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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