Struct rgx::math::transform::Transform3D

source ·
#[repr(C)]
pub struct Transform3D<S = f32, Src = (), Dst = ()> { pub x: Vector4D<S>, pub y: Vector4D<S>, pub z: Vector4D<S>, pub w: Vector4D<S>, /* private fields */ }
Expand description

A 4 x 4, column major matrix

This type is marked as #[repr(C)].

Fields§

§x: Vector4D<S>

The first column of the matrix.

§y: Vector4D<S>

The second column of the matrix.

§z: Vector4D<S>

The third column of the matrix.

§w: Vector4D<S>

The fourth column of the matrix.

Implementations§

source§

impl<S: Zero + One, Src, Dst> Transform3D<S, Src, Dst>

source

pub fn new( m11: S, m12: S, m13: S, m14: S, m21: S, m22: S, m23: S, m24: S, m31: S, m32: S, m33: S, m34: S, m41: S, m42: S, m43: S, m44: S ) -> Self

Create a new matrix, providing values for each index.

source

pub fn new_2d(m11: S, m12: S, m21: S, m22: S, m41: S, m42: S) -> Selfwhere S: Zero + One,

Create a transform representing a 2d transformation from the components of a 2 by 3 matrix transformation.

Components follow the column-major-column-vector notation (m41 and m42 representating the translation terms).

m11  m12   0   0
m21  m22   0   0
  0    0   1   0
m41  m42   0   1
source

pub fn identity() -> Self

source

pub fn from_nonuniform_scale(x: S, y: S, z: S) -> Transform3D<S, Src, Dst>

Create a homogeneous transformation matrix from a set of scale values.

source§

impl<S: Copy + Zero + One, Src, Dst> Transform3D<S, Src, Dst>

source

pub fn row(&self, n: usize) -> Vector4D<S>

source

pub fn translation(&self) -> Vector3D<S>

source

pub fn from_translation(v: impl Into<Vector3D<S>>) -> Transform3D<S, Src, Dst>

Create a homogeneous transformation matrix from a translation vector.

source

pub fn scale(&self) -> Vector3D<S>

source

pub fn from_scale(value: S) -> Transform3D<S, Src, Dst>

Create a homogeneous transformation matrix from a scale value.

source§

impl<Src, Dst> Transform3D<f32, Src, Dst>

source

pub fn ortho(size: impl Into<Size<u32>>, origin: Origin) -> Self

Create orthographic matrix.

source

pub fn offset(&self) -> Offset

source§

impl<T, Src, Dst> Transform3D<T, Src, Dst>where T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + One + Zero,

source

pub fn is_invertible(&self) -> bool

Returns whether it is possible to compute the inverse transform.

source

pub fn inverse(&self) -> Transform3D<T, Dst, Src>

Return the inverse transform.

Panics if the transform is not invertible.

source

pub fn try_inverse(&self) -> Option<Transform3D<T, Dst, Src>>

Returns the inverse transform if possible.

source

pub fn determinant(&self) -> T

Compute the determinant of the transform.

Trait Implementations§

source§

impl<S: Clone, Src: Clone, Dst: Clone> Clone for Transform3D<S, Src, Dst>

source§

fn clone(&self) -> Transform3D<S, Src, Dst>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Debug, Src: Debug, Dst: Debug> Debug for Transform3D<S, Src, Dst>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: Float, Src, Dst> From<Ortho<S>> for Transform3D<S, Src, Dst>

source§

fn from(ortho: Ortho<S>) -> Self

Converts to this type from the input type.
source§

impl<S: One + Zero + Copy> From<Point2D<S, ()>> for Transform3D<S>

source§

fn from(other: Point2D<S>) -> Self

Converts to this type from the input type.
source§

impl<Src, Dst> From<Transform2D<Src, Dst>> for Transform3D<f32, Src, Dst>

source§

fn from(m: Transform2D<Src, Dst>) -> Self

Create a 3D transform from the current transform

source§

impl From<Transform3D<f32, (), ()>> for [[f32; 4]; 4]

source§

fn from(mat: Transform3D<f32>) -> Self

Converts to this type from the input type.
source§

impl<S: One + Zero + Copy> From<Vector2D<S, ()>> for Transform3D<S>

source§

fn from(other: Vector2D<S>) -> Self

Converts to this type from the input type.
source§

impl Mul<Point2D<f32, ()>> for Transform3D<f32>

Transform a Point2D with a Transform3D.

use rgx::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let p = Point2D::new(1., 1.);

assert_eq!(m * p, Point2D::new(9., 9.));
§

type Output = Point2D<f32, ()>

The resulting type after applying the * operator.
source§

fn mul(self, p: Point2D<f32>) -> Point2D<f32>

Performs the * operation. Read more
source§

impl<S: Copy + Zero + One + Mul<Output = S>, Src, Dst> Mul<S> for Transform3D<S, Src, Dst>

Multiplies all of the transform’s component by a scalar and returns the result.

§

type Output = Transform3D<S, Src, Dst>

The resulting type after applying the * operator.
source§

fn mul(self, x: S) -> Self

Performs the * operation. Read more
source§

impl<S, Src, Dst, NewDst> Mul<Transform3D<S, Dst, NewDst>> for Transform3D<S, Src, Dst>where S: Mul<Output = S> + Add<Output = S> + Copy,

§

type Output = Transform3D<S, Src, NewDst>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Transform3D<S, Dst, NewDst>) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vector2D<f32, ()>> for Transform3D<f32>

Transform a Vector2D with a Transform3D.

use rgx::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let v = Vector2D::new(1., 1.);

assert_eq!(m * v, Vector2D::new(9., 9.));
§

type Output = Vector2D<f32, ()>

The resulting type after applying the * operator.
source§

fn mul(self, vec: Vector2D<f32>) -> Vector2D<f32>

Performs the * operation. Read more
source§

impl Mul<Vector3D<f32, ()>> for Transform3D<f32>

Transform a Vector3D with a Transform3D.

use rgx::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let v = Vector3D::new(1., 1., 0.);

assert_eq!(m * v, Vector3D::new(9., 9., 0.));
§

type Output = Vector3D<f32, ()>

The resulting type after applying the * operator.
source§

fn mul(self, vec: Vector3D<f32>) -> Vector3D<f32>

Performs the * operation. Read more
source§

impl Mul<Vector4D<f32, ()>> for Transform3D<f32>

Transform a Vector4D with a Transform3D.

use rgx::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let v = Vector4D::new(1., 1., 0., 1.);

assert_eq!(m * v, Vector4D::new(9., 9., 0., 1.));
§

type Output = Vector4D<f32, ()>

The resulting type after applying the * operator.
source§

fn mul(self, vec: Vector4D<f32>) -> Vector4D<f32>

Performs the * operation. Read more
source§

impl<S: PartialEq, Src: PartialEq, Dst: PartialEq> PartialEq<Transform3D<S, Src, Dst>> for Transform3D<S, Src, Dst>

source§

fn eq(&self, other: &Transform3D<S, Src, Dst>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Uniformable<'a, Transform3D<f32, (), ()>> for GL33

§

type Target = Transform3D<f32, (), ()>

source§

const SIZE: usize = 1usize

Return the size of the uniform. Read more
source§

unsafe fn ty() -> UniformType

Reify the type of the uniform as a UniformType.
source§

unsafe fn update( _program: &mut Self::ProgramRepr, uniform: &'a Uniform<Transform3D>, transform: Self::Target )

Update the associated value of the Uniform in the given shader program.
source§

impl<S: Copy, Src: Copy, Dst: Copy> Copy for Transform3D<S, Src, Dst>

source§

impl<S, Src, Dst> StructuralPartialEq for Transform3D<S, Src, Dst>

Auto Trait Implementations§

§

impl<S, Src, Dst> RefUnwindSafe for Transform3D<S, Src, Dst>where Dst: RefUnwindSafe, S: RefUnwindSafe, Src: RefUnwindSafe,

§

impl<S, Src, Dst> Send for Transform3D<S, Src, Dst>where Dst: Send, S: Send, Src: Send,

§

impl<S, Src, Dst> Sync for Transform3D<S, Src, Dst>where Dst: Sync, S: Sync, Src: Sync,

§

impl<S, Src, Dst> Unpin for Transform3D<S, Src, Dst>where Dst: Unpin, S: Unpin, Src: Unpin,

§

impl<S, Src, Dst> UnwindSafe for Transform3D<S, Src, Dst>where Dst: UnwindSafe, S: UnwindSafe, Src: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.