[−][src]Struct pbrt::core::transform::Transform
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]
V: Into<Vector3f>,
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]
V: Into<Vector3f>,
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.
fn mul(self, rhs: &'b mut Transform) -> Transform
[src]
impl Mul<Transform> for Transform
[src]
type Output = Transform
The resulting type after applying the *
operator.
fn mul(self, rhs: Transform) -> Transform
[src]
impl PartialEq<Transform> for Transform
[src]
impl StructuralPartialEq for Transform
[src]
Auto Trait Implementations
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,