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

pub struct Transform { /* fields omitted */ }

Transform represents a Matrix4x4 and its inverse.

Methods

impl Transform[src]

pub fn identity() -> Transform[src]

Returns a new Transform set to the identity matrix.

Examples

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

assert_eq!(
    Transform::identity(),
    Matrix4x4::new(
        [1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

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

Returns the inverse Transform of self.

Examples

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

let t = Transform::identity();
assert_eq!(
    t.inverse(),
    Matrix4x4::new(
        [1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

pub fn translate<V>(delta: V) -> Transform where
    V: Into<Vector3f>, 
[src]

Creates a Transform representing the given translate factors.

Examples

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

assert_eq!(
    Transform::translate([2., 4., 6.]),
    Matrix4x4::new(
        [1., 0., 0., 2.],
        [0., 1., 0., 4.],
        [0., 0., 1., 6.],
        [0., 0., 0., 1.]
    )
    .into()
);

pub fn rotate<V>(theta: Degree, axis: V) -> Transform where
    V: Into<Vector3f>, 
[src]

Creates a Transform representing a rotation of theta about axis.

Examples

use pbrt::core::transform::Matrix4x4;
use pbrt::core::transform::Transform;
use pbrt::Degree;
use pbrt::Float;

let t_deg: Float = 180.;
let t_rad = t_deg.to_radians();
let s = t_rad.sin();
let c = t_rad.cos();

// Rotate about the x-axis.
assert_eq!(
    Transform::rotate(t_deg.into(), [1., 0., 0.]),
    Matrix4x4::new(
        [1., 0., 0., 0.],
        [0., c, -s, 0.],
        [0., s, c, 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

// Rotate about the y-axis.
assert_eq!(
    Transform::rotate(t_deg.into(), [0., 1., 0.]),
    Matrix4x4::new(
        [c, 0., s, 0.],
        [0., 1., 0., 0.],
        [-s, 0., c, 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

// Rotate about the z-axis.
assert_eq!(
    Transform::rotate(t_deg.into(), [0., 0., 1.]),
    Matrix4x4::new(
        [c, -s, 0., 0.],
        [s, c, 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

pub fn scale(sx: Float, sy: Float, sz: Float) -> Transform[src]

Creates a Transform representing the given scale factors.

Examples

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

assert_eq!(
    Transform::scale(2., 4., 6.),
    Matrix4x4::new(
        [2., 0., 0., 0.],
        [0., 4., 0., 0.],
        [0., 0., 6., 0.],
        [0., 0., 0., 1.]
    )
    .into()
);

pub fn matrix(self) -> Matrix4x4[src]

Returns the internal Matrix4x4 of self.

Examples

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

let t = Transform::identity();
assert_eq!(
    t.matrix(),
    Matrix4x4::new(
        [1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]
    )
);

pub fn matrix_inverse(self) -> Matrix4x4[src]

Returns the internal inverse Matrix4x4 of self.

Examples

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

let t = Transform::identity();
assert_eq!(
    t.matrix_inverse(),
    Matrix4x4::new(
        [1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]
    )
);

Trait Implementations

impl Clone for Transform[src]

impl Copy for Transform[src]

impl Debug for Transform[src]

impl Default for Transform[src]

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

impl From<Matrix4x4> for Transform[src]

impl<'a, 'b> Mul<&'b mut Transform> for &'a mut Transform[src]

type Output = Transform

The resulting type after applying the * operator.

impl Mul<Transform> for Transform[src]

type Output = Transform

The resulting type after applying the * operator.

impl PartialEq<Transform> for Transform[src]

impl StructuralPartialEq for Transform[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.