#[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) -> Self
pub fn new_2d(m11: S, m12: S, m21: S, m22: S, m41: S, m42: S) -> Self
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>
impl<T, Src, Dst> Transform3D<T, Src, Dst>
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> for [[f32; 4]; 4]
impl From<Transform3D> for [[f32; 4]; 4]
Source§fn from(mat: Transform3D<f32>) -> Self
fn from(mat: Transform3D<f32>) -> Self
Source§impl Mul<Point2D> for Transform3D<f32>
Transform a Point2D
with a Transform3D
.
impl Mul<Point2D> 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>
Multiplies all of the transform’s component by a scalar and returns the result.
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>
impl<S, Src, Dst, NewDst> Mul<Transform3D<S, Dst, NewDst>> for Transform3D<S, Src, Dst>
Source§type Output = Transform3D<S, Src, NewDst>
type Output = Transform3D<S, Src, NewDst>
*
operator.Source§impl Mul<Vector2D> for Transform3D<f32>
Transform a Vector2D
with a Transform3D
.
impl Mul<Vector2D> 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> for Transform3D<f32>
Transform a Vector3D
with a Transform3D
.
impl Mul<Vector3D> 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> for Transform3D<f32>
Transform a Vector4D
with a Transform3D
.
impl Mul<Vector4D> 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<'a> Uniformable<'a, Transform3D> for GL33
impl<'a> Uniformable<'a, Transform3D> for GL33
type Target = Transform3D
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.