[][src]Struct pbrt::core::transform::Matrix4x4

pub struct Matrix4x4 { /* fields omitted */ }

Matrix4x4 represents a 4x4 matrix in row-major form. So, element m[i][j] corresponds to mi,j where i is the row number and j is the column number.

Methods

impl Matrix4x4[src]

pub fn identity() -> Matrix4x4[src]

Create a Matrix4x4 containing the identity, all zeros with ones along the diagonal.

pub fn new(
    r0: [Float; 4],
    r1: [Float; 4],
    r2: [Float; 4],
    r3: [Float; 4]
) -> Matrix4x4
[src]

Create a Matrix4x4 with each of the given rows.

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

Transpose self, returning a new matrix that has been reflected across the diagonal.

Examples

use pbrt::core::transform::Matrix4x4;

let m = Matrix4x4::new(
    [2., 0., 0., 0.],
    [3., 1., 0., 0.],
    [4., 0., 1., 0.],
    [5., 6., 7., 1.],
);
let m_t = Matrix4x4::new(
    [2., 3., 4., 5.],
    [0., 1., 0., 6.],
    [0., 0., 1., 7.],
    [0., 0., 0., 1.],
);
assert_eq!(m.transpose(), m_t);

pub fn inverse(&self) -> Matrix4x4[src]

Returns a new matrix that is the inverse of self. If self is A, inverse returns A-1, where AA-1 = I. This implementation uses a numerically stable Gauss–Jordan elimination routine to compute the inverse.

Examples

use pbrt::core::transform::Matrix4x4;

let i = Matrix4x4::identity();
assert_eq!(i.inverse() * i, i);

let m = Matrix4x4::new(
    [2., 0., 0., 0.],
    [0., 3., 0., 0.],
    [0., 0., 4., 0.],
    [0., 0., 0., 1.],
);
assert_eq!(m.inverse() * m, i);
assert_eq!(m * m.inverse(), i);

Trait Implementations

impl Clone for Matrix4x4[src]

impl Copy for Matrix4x4[src]

impl Debug for Matrix4x4[src]

impl Default for Matrix4x4[src]

impl From<[f32; 16]> for Matrix4x4[src]

impl From<Matrix4x4> for Transform[src]

impl Mul<Matrix4x4> for Matrix4x4[src]

type Output = Matrix4x4

The resulting type after applying the * operator.

fn mul(self, m2: Matrix4x4) -> Matrix4x4[src]

Implement matrix multiplication for Matrix4x4.

Examples

use pbrt::core::transform::Matrix4x4;

let i = Matrix4x4::identity();
let m1 = Matrix4x4::identity();
let m2 = Matrix4x4::identity();

assert_eq!(m1 * m2, i);

impl PartialEq<Matrix4x4> for Matrix4x4[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> SetParameter for T

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

type Owned = T

The resulting type after obtaining ownership.

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.