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>
impl<S: Zero + One, Src, Dst> Transform3D<S, Src, Dst>
sourcepub 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
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.
sourcepub fn new_2d(m11: S, m12: S, m21: S, m22: S, m41: S, m42: S) -> Selfwhere
S: Zero + One,
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
pub fn identity() -> Self
sourcepub fn from_nonuniform_scale(x: S, y: S, z: S) -> Transform3D<S, Src, Dst>
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>
impl<S: Copy + Zero + One, Src, Dst> Transform3D<S, Src, Dst>
pub fn row(&self, n: usize) -> Vector4D<S>
pub fn translation(&self) -> Vector3D<S>
sourcepub fn from_translation(v: impl Into<Vector3D<S>>) -> Transform3D<S, Src, Dst>
pub fn from_translation(v: impl Into<Vector3D<S>>) -> Transform3D<S, Src, Dst>
Create a homogeneous transformation matrix from a translation vector.
pub fn scale(&self) -> Vector3D<S>
sourcepub fn from_scale(value: S) -> Transform3D<S, Src, Dst>
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>
impl<Src, Dst> Transform3D<f32, Src, Dst>
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,
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,
sourcepub fn is_invertible(&self) -> bool
pub fn is_invertible(&self) -> bool
Returns whether it is possible to compute the inverse transform.
sourcepub fn inverse(&self) -> Transform3D<T, Dst, Src>
pub fn inverse(&self) -> Transform3D<T, Dst, Src>
Return the inverse transform.
Panics if the transform is not invertible.
sourcepub fn try_inverse(&self) -> Option<Transform3D<T, Dst, Src>>
pub fn try_inverse(&self) -> Option<Transform3D<T, Dst, Src>>
Returns the inverse transform if possible.
sourcepub fn determinant(&self) -> T
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>
impl<S: Clone, Src: Clone, Dst: Clone> Clone for Transform3D<S, Src, Dst>
source§fn clone(&self) -> Transform3D<S, Src, Dst>
fn clone(&self) -> Transform3D<S, Src, Dst>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Src, Dst> From<Transform2D<Src, Dst>> for Transform3D<f32, Src, Dst>
impl<Src, Dst> From<Transform2D<Src, Dst>> for Transform3D<f32, Src, Dst>
source§fn from(m: Transform2D<Src, Dst>) -> Self
fn from(m: Transform2D<Src, Dst>) -> Self
Create a 3D transform from the current transform
source§impl From<Transform3D<f32, (), ()>> for [[f32; 4]; 4]
impl From<Transform3D<f32, (), ()>> for [[f32; 4]; 4]
source§fn from(mat: Transform3D<f32>) -> Self
fn from(mat: Transform3D<f32>) -> Self
source§impl Mul<Point2D<f32, ()>> for Transform3D<f32>
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.));
source§impl<S: Copy + Zero + One + Mul<Output = S>, Src, Dst> Mul<S> for Transform3D<S, Src, Dst>
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.
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,
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>
type Output = Transform3D<S, Src, NewDst>
*
operator.source§impl Mul<Vector2D<f32, ()>> for Transform3D<f32>
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.));
source§impl Mul<Vector3D<f32, ()>> for Transform3D<f32>
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.));
source§impl Mul<Vector4D<f32, ()>> for Transform3D<f32>
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.));
source§impl<S: PartialEq, Src: PartialEq, Dst: PartialEq> PartialEq<Transform3D<S, Src, Dst>> for Transform3D<S, Src, Dst>
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
fn eq(&self, other: &Transform3D<S, Src, Dst>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> Uniformable<'a, Transform3D<f32, (), ()>> for GL33
impl<'a> Uniformable<'a, Transform3D<f32, (), ()>> for GL33
type Target = Transform3D<f32, (), ()>
source§unsafe fn ty() -> UniformType
unsafe fn ty() -> UniformType
UniformType
.source§unsafe fn update(
_program: &mut Self::ProgramRepr,
uniform: &'a Uniform<Transform3D>,
transform: Self::Target
)
unsafe fn update( _program: &mut Self::ProgramRepr, uniform: &'a Uniform<Transform3D>, transform: Self::Target )
Uniform
in the given shader program.