pub struct Matrix4<F: Float> { /* private fields */ }Implementations§
Source§impl<F: Float> Matrix4<F>
impl<F: Float> Matrix4<F>
Sourcepub fn new(
m00: F,
m01: F,
m02: F,
m03: F,
m10: F,
m11: F,
m12: F,
m13: F,
m20: F,
m21: F,
m22: F,
m23: F,
m30: F,
m31: F,
m32: F,
m33: F,
) -> Matrix4<F>
pub fn new( m00: F, m01: F, m02: F, m03: F, m10: F, m11: F, m12: F, m13: F, m20: F, m21: F, m22: F, m23: F, m30: F, m31: F, m32: F, m33: F, ) -> Matrix4<F>
New 4x4 matrix from 16 values.
use math3d::matrices::Matrix4;
let m = Matrix4::new(
1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0);
assert!(m.m[0][0] == 1.0);
assert!(m.m[3][3] == 16.0);Sourcepub fn identity() -> Matrix4<F>
pub fn identity() -> Matrix4<F>
New 4x4 identity matrix.
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
assert!(m.m[0][0] == 1.0);
assert!(m.m[3][3] == 1.0);Sourcepub fn zero() -> Matrix4<F>
pub fn zero() -> Matrix4<F>
New 4x4 zero matrix.
use math3d::matrices::Matrix4;
let m = Matrix4::zero();
assert!(m.m[0][0] == 0.0);
assert!(m.m[3][3] == 0.0);Sourcepub fn from_vectors(
v0: Vector4<F>,
v1: Vector4<F>,
v2: Vector4<F>,
v3: Vector4<F>,
) -> Matrix4<F>
pub fn from_vectors( v0: Vector4<F>, v1: Vector4<F>, v2: Vector4<F>, v3: Vector4<F>, ) -> Matrix4<F>
New 4x4 matrix from array of 4 vectors.
use math3d::matrices::Matrix4;
let m = Matrix4::from_vectors(
Vector4::new(1.0, 2.0, 3.0, 4.0),
Vector4::new(5.0, 6.0, 7.0, 8.0),
Vector4::new(9.0, 10.0, 11.0, 12.0),
Vector4::new(13.0, 14.0, 15.0, 16.0));
assert!(m.m[0][0] == 1.0);
assert!(m.m[3][3] == 16.0);Sourcepub fn from_array(m: [F; 16]) -> Matrix4<F>
pub fn from_array(m: [F; 16]) -> Matrix4<F>
New 4x4 matrix from array of 16 values.
use math3d::matrices::Matrix4;
let m = Matrix4::from_array([
1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
13.0, 14.0, 15.0, 16.0]);
assert!(m.m[0][0] == 1.0);
assert!(m.m[3][3] == 16.0);Sourcepub fn index(&self, index: usize) -> &F
pub fn index(&self, index: usize) -> &F
Index into matrix.
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
assert!(m[0][0] == 1.0);
assert!(m[3][3] == 1.0);Sourcepub fn to_array_f32(&self) -> [f32; 16]
pub fn to_array_f32(&self) -> [f32; 16]
To array f32.
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
let af32 = m.to_array_f32();
assert!(af32[0] == 1.0);
assert!(af32[15] == 1.0);Sourcepub fn to_array_f64(&self) -> [f64; 16]
pub fn to_array_f64(&self) -> [f64; 16]
To array f64
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
let af64 = m.to_array_f64();
assert!(af64[0] == 1.0);
assert!(af64[15] == 1.0);Sourcepub fn to_array_vectors(&self) -> [Vector4<F>; 4]
pub fn to_array_vectors(&self) -> [Vector4<F>; 4]
To array of vectors.
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
let av = m.to_array_vectors();
assert!(av[0][0] == 1.0);
assert!(av[3][3] == 1.0);Sourcepub fn product(&self, other: Matrix4<F>) -> Matrix4<F>
pub fn product(&self, other: Matrix4<F>) -> Matrix4<F>
Multiply 4x4 matrix by 4x4 matrix.
use math3d::matrices::Matrix4;
let m1 = Matrix4::identity();
let m2 = Matrix4::identity();
let m3 = m1 * m2;
assert!(m3 == m2);Sourcepub fn product_vector(&self, other: Vector4<F>) -> Vector4<F>
pub fn product_vector(&self, other: Vector4<F>) -> Vector4<F>
Multiply 4x4 matrix by 4x1 vector.
use math3d::matrices::Matrix4;
let m = Matrix4::identity();
let v = m * Vector4::new(1.0, 2.0, 3.0, 4.0);
assert!(v == Vector4::new(1.0, 2.0, 3.0, 4.0));Trait Implementations§
impl<F: Copy + Float> Copy for Matrix4<F>
Auto Trait Implementations§
impl<F> Freeze for Matrix4<F>
impl<F> RefUnwindSafe for Matrix4<F>
impl<F> Send for Matrix4<F>
impl<F> Sync for Matrix4<F>
impl<F> Unpin for Matrix4<F>
impl<F> UnsafeUnpin for Matrix4<F>
impl<F> UnwindSafe for Matrix4<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more