Struct Matrix4

Source
#[repr(C, packed(1))]
pub struct Matrix4 { pub m: [f32; 16], }

Fields§

§m: [f32; 16]

Implementations§

Source§

impl Matrix4

Source

pub fn new() -> Matrix4

Creates a matrix set to its identity

§Examples
use vex::Matrix4;
 
let actual = Matrix4::new();
assert_eq!(actual, Matrix4 {
    m: [
        1.0, 0.0, 0.0, 0.0,
        0.0, 1.0, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0,
        0.0, 0.0, 0.0, 1.0,
    ],
});
Source

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

Creates a matrix from the provided values

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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);
let expected = [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_eq!(actual.m, expected);
Source

pub fn ortho( left: f32, right: f32, top: f32, bottom: f32, near: f32, far: f32, ) -> Matrix4

Creates a orthogonal projection matrix

§Examples
use vex::Matrix4;

let actual = Matrix4::ortho(-960.0, 960.0, 540.0, -540.0, -100.0, 100.0);
let expected = [
     0.0010416667,  0.0,           0.0,  0.0, // column 1
     0.0,           0.0018518518,  0.0,  0.0, // column 2
     0.0,           0.0,          -0.01, 0.0, // column 3
    -0.0,          -0.0,          -0.0,  1.0, // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn perspective(fov: f32, aspect_ratio: f32, near: f32, far: f32) -> Matrix4

Creates a orthogonal projection matrix

§Examples
use vex::Matrix4;

let width = 1920;
let height = 1080;
let aspect_ratio = width as f32 / height as f32;
let actual = Matrix4::perspective(75.0, aspect_ratio, 1.0, 1000.0);
let expected = [
     0.73306423,  0.0,        0.0,       0.0,      // column 1
     0.0,         1.3032253,  0.0,       0.0,      // column 2
     0.0,         0.0,       -1.002002, -2.002002, // column 3
     0.0,         0.0,        0.0,       0.0       // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn look_at(position: Vector3, target: Vector3, up: Vector3) -> Matrix4

Creates a look-at matrix

§Examples
use vex::Matrix4;
use vex::Vector3;

let position = Vector3::make(0.0, 1.0, 1.0);
let target = Vector3::new();
let actual = Matrix4::look_at(position, target, Vector3::up());
let expected = [
  1.0, 0.0,         0.0,        0.0, // column 1
  0.0, 0.70710677, -0.70710677, 0.0, // column 2
  0.0, 0.70710677,  0.70710677, 0.0, // column 3
  0.0, 1.0,         1.0,        1.0, // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn translate(x: f32, y: f32, z: f32) -> Matrix4

Creates a translation matrix

§Examples
use vex::Matrix4;
use vex::Vector3;

let position = Vector3::make(0.0, 1.0, 1.0);
let target = Vector3::new();
let actual = Matrix4::translate(1.0, 2.0, 3.0);
let expected = [
  1.0, 0.0, 0.0, 0.0, // column 1
  0.0, 1.0, 0.0, 0.0, // column 2
  0.0, 0.0, 1.0, 0.0, // column 3
  1.0, 2.0, 3.0, 1.0, // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn rotate_x(angle: f32) -> Matrix4

Creates an x-rotation matrix

§Examples
use vex::Matrix4;
use vex::Vector3;

let actual = Matrix4::rotate_x(1.5707);
let expected = [
    1.0,  0.0,           0.0,           0.0,
    0.0,  0.00009627739, 1.0,           0.0,
    0.0, -1.0,           0.00009627739, 0.0,
    0.0,  0.0,           0.0,           1.0,
];

assert_eq!(actual.m, expected);
Source

pub fn rotate_y(angle: f32) -> Matrix4

Creates an y-rotation matrix

§Examples
use vex::Matrix4;
use vex::Vector3;

let actual = Matrix4::rotate_y(1.5707);
let expected = [
    0.00009627739,  0.0, 1.0,           0.0, // column 1
    0.0,            1.0, 0.0,           0.0, // column 2
    0.0,            0.0, 0.00009627739, 0.0, // column 3
    0.0,            0.0, 0.0,           1.0, // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn rotate_z(angle: f32) -> Matrix4

Creates an z-rotation matrix

§Examples
use vex::Matrix4;
use vex::Vector3;

let actual = Matrix4::rotate_z(1.5707);
let expected = [
    0.00009627739, -1.0,           0.0, 0.0, // column 1
    1.0,            0.00009627739, 0.0, 0.0, // column 2
    0.0,            0.0,           1.0, 0.0, // column 3
    0.0,            0.0,           0.0, 1.0, // column 4
];

assert_eq!(actual.m, expected);
Source

pub fn scale(x: f32, y: f32, z: f32) -> Matrix4

Creates a scale matrix

§Examples
use vex::Matrix4;
 
let actual = Matrix4::scale(1.0, 2.0, 3.0);
let expected = [
    1.0, 0.0, 0.0, 0.0, // column 1
    0.0, 2.0, 0.0, 0.0, // column 2
    0.0, 0.0, 3.0, 0.0, // column 3
    0.0, 0.0, 0.0, 1.0, // column 4
];
assert_eq!(actual.m, expected);
Source

pub fn m11(&self) -> f32

Gets the value for the m11 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m11(), 1.0);
Source

pub fn m21(&self) -> f32

Gets the value for the m21 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m21(), 2.0);
Source

pub fn m31(&self) -> f32

Gets the value for the m31 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m31(), 3.0);
Source

pub fn m41(&self) -> f32

Gets the value for the m41 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m41(), 4.0);
Source

pub fn m12(&self) -> f32

Gets the value for the m12 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m12(), 5.0);
Source

pub fn m22(&self) -> f32

Gets the value for the m22 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m22(), 6.0);
Source

pub fn m32(&self) -> f32

Gets the value for the m32 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m32(), 7.0);
Source

pub fn m42(&self) -> f32

Gets the value for the m42 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m42(), 8.0);
Source

pub fn m13(&self) -> f32

Gets the value for the m13 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m13(), 9.0);
Source

pub fn m23(&self) -> f32

Gets the value for the m23 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m23(), 10.0);
Source

pub fn m33(&self) -> f32

Gets the value for the m33 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m33(), 11.0);
Source

pub fn m43(&self) -> f32

Gets the value for the m43 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m43(), 12.0);
Source

pub fn m14(&self) -> f32

Gets the value for the m14 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m14(), 13.0);
Source

pub fn m24(&self) -> f32

Gets the value for the m24 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m24(), 14.0);
Source

pub fn m34(&self) -> f32

Gets the value for the m34 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m34(), 15.0);
Source

pub fn m44(&self) -> f32

Gets the value for the m44 element

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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_eq!(actual.m44(), 16.0);
Source

pub fn set_m11(&mut self, v: f32)

Sets the value for the m11 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m11(1.0);
let expected = [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m21(&mut self, v: f32)

Sets the value for the m21 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m21(1.0);
let expected = [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m31(&mut self, v: f32)

Sets the value for the m31 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m31(1.0);
let expected = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m41(&mut self, v: f32)

Sets the value for the m41 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m41(1.0);
let expected = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m12(&mut self, v: f32)

Sets the value for the m12 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m12(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m22(&mut self, v: f32)

Sets the value for the m22 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m22(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m32(&mut self, v: f32)

Sets the value for the m32 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m32(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m42(&mut self, v: f32)

Sets the value for the m42 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m42(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m13(&mut self, v: f32)

Sets the value for the m13 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m13(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m23(&mut self, v: f32)

Sets the value for the m23 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m23(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m33(&mut self, v: f32)

Sets the value for the m33 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m33(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m43(&mut self, v: f32)

Sets the value for the m43 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m43(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m14(&mut self, v: f32)

Sets the value for the m14 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m14(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m24(&mut self, v: f32)

Sets the value for the m24 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m24(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m34(&mut self, v: f32)

Sets the value for the m34 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m34(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0];
assert_eq!(actual.m, expected);
Source

pub fn set_m44(&mut self, v: f32)

Sets the value for the m44 element

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
actual.set_m44(1.0);
let expected = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0];
assert_eq!(actual.m, expected);
Source

pub fn set( &mut self, m11: f32, m21: f32, m31: f32, m41: f32, m12: f32, m22: f32, m32: f32, m42: f32, m13: f32, m23: f32, m33: f32, m43: f32, m14: f32, m24: f32, m34: f32, m44: f32, )

Sets the internal contents of the matrix

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::new();
actual.set(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);
let expected = Matrix4::make(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_eq!(actual, expected);
Source

pub fn transpose(&mut self)

Transposes the matrix’s elements

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual.transpose();
let expected = Matrix4::make(1.0, 5.0, 9.0, 13.0, 2.0, 6.0, 10.0, 14.0, 3.0, 7.0, 11.0, 15.0, 4.0, 8.0, 12.0, 16.0);
assert_eq!(actual, expected);
Source

pub fn determinant(&self) -> f32

Find the matrix’s determinant

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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).determinant();
assert_eq!(actual, 0.0);
Source

pub fn inverse(&mut self) -> bool

Inverses the matrix

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 2.0, 1.0, 4.0);
actual.inverse();
let expected = Matrix4::make(-2.0, 1.0, -8.0, 3.0, -0.5, 0.5, -1.0, 0.5, 1.0, 0.0, 2.0, -1.0, 0.5, -0.5, 2.0, -0.5);
assert_eq!(actual, expected);
Source

pub fn is_valid(&self) -> bool

Determine whether or not all elements of the matrix are valid

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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!(actual.is_valid());

Trait Implementations§

Source§

impl Add<f32> for Matrix4

Source§

fn add(self, _rhs: f32) -> Matrix4

Find the resulting matrix by adding a scalar to a matrix’s elements

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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) + 1.0;
let expected = Matrix4::make(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, 17.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the + operator.
Source§

impl Add for Matrix4

Source§

fn add(self, _rhs: Matrix4) -> Matrix4

Add two matrices

§Examples
use vex::Matrix4;
 
let a = Matrix4::make(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);
let b = Matrix4::make(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
let actual = a + b;
let expected = Matrix4::make(17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the + operator.
Source§

impl AddAssign<f32> for Matrix4

Source§

fn add_assign(&mut self, _rhs: f32)

Increment a matrix by a scalar

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual += 10.0;
let expected = Matrix4::make(11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
assert_eq!(actual, expected);
Source§

impl AddAssign for Matrix4

Source§

fn add_assign(&mut self, _rhs: Matrix4)

Increment a matrix by another matrix

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual += Matrix4::make(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
let expected = Matrix4::make(17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0);
assert_eq!(actual, expected);
Source§

impl Clone for Matrix4

Source§

fn clone(&self) -> Matrix4

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 Debug for Matrix4

Source§

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

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

impl Display for Matrix4

Source§

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

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

impl Div<f32> for Matrix4

Source§

fn div(self, _rhs: f32) -> Matrix4

Find the resulting matrix by dividing a scalar to a matrix’s elements

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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) / 2.0;
let expected = Matrix4::make(0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the / operator.
Source§

impl DivAssign<f32> for Matrix4

Source§

fn div_assign(&mut self, _rhs: f32)

Divide a matrix by a scalar

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual /= 2.0;
let expected = Matrix4::make(0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0);
assert_eq!(actual, expected);
Source§

impl Matrix<Vector3> for Matrix4

Source§

fn transform_point(&self, point: &Vector3) -> Vector3

Find the resulting vector given a vector and matrix

§Examples
use vex::Matrix;
use vex::Matrix4;
use vex::Vector3;
 
let m = Matrix4::make(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);
let v = Vector3::make(1.0, 2.0, 3.0);
let actual = m.transform_point(&v);
let expected = Vector3::make(51.0, 58.0, 65.0);
assert_eq!(actual, expected);
Source§

impl Matrix<Vector4> for Matrix4

Source§

fn transform_point(&self, point: &Vector4) -> Vector4

Find the resulting vector given a vector and matrix

§Examples
use vex::Matrix;
use vex::Matrix4;
use vex::Vector4;
 
let m = Matrix4::make(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);
let v = Vector4::make(1.0, 2.0, 3.0, 4.0);
let actual = m.transform_point(&v);
let expected = Vector4::make(90.0, 100.0, 110.0, 120.0);
assert_eq!(actual, expected);
Source§

impl Mul<f32> for Matrix4

Source§

fn mul(self, _rhs: f32) -> Matrix4

Find the resulting matrix by multiplying a scalar to a matrix’s elements

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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) * 2.0;
let expected = Matrix4::make(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the * operator.
Source§

impl Mul for Matrix4

Source§

fn mul(self, _rhs: Matrix4) -> Matrix4

Multiply two matrices

§Examples
use vex::Matrix4;
 
let a = Matrix4::make(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);
let b = Matrix4::make(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
let actual = a * b;
let expected = Matrix4::make(
  386.0, 444.0, 502.0, 560.0,
  274.0, 316.0, 358.0, 400.0,
  162.0, 188.0, 214.0, 240.0,
   50.0,  60.0,  70.0,  80.0,
);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the * operator.
Source§

impl MulAssign<f32> for Matrix4

Source§

fn mul_assign(&mut self, _rhs: f32)

Multiply a matrix by a scalar

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual *= 2.0;
let expected = Matrix4::make(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0);
assert_eq!(actual, expected);
Source§

impl MulAssign for Matrix4

Source§

fn mul_assign(&mut self, _rhs: Matrix4)

Multiply a matrix by another matrix

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual *= Matrix4::make(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
let expected = Matrix4::make(
  386.0, 444.0, 502.0, 560.0,
  274.0, 316.0, 358.0, 400.0,
  162.0, 188.0, 214.0, 240.0,
   50.0,  60.0,  70.0,  80.0,
);
assert_eq!(actual, expected);
Source§

impl Neg for Matrix4

Source§

fn neg(self) -> Matrix4

Negates the matrix’s elements

§Examples
use vex::Matrix4;
 
let actual = -Matrix4::make(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);
let expected = Matrix4::make(-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_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the - operator.
Source§

impl PartialEq for Matrix4

Source§

fn eq(&self, _rhs: &Matrix4) -> bool

Determines if two matrices’ elements are equivalent

§Examples
use vex::Matrix4;
 
assert!(Matrix4::new() == Matrix4::new());
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub<f32> for Matrix4

Source§

fn sub(self, _rhs: f32) -> Matrix4

Find the resulting matrix by subtracting a scalar from a matrix’s elements

§Examples
use vex::Matrix4;
 
let actual = Matrix4::make(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) - 17.0;
let expected = Matrix4::make(-16.0, -15.0, -14.0, -13.0, -12.0, -11.0, -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the - operator.
Source§

impl Sub for Matrix4

Source§

fn sub(self, _rhs: Matrix4) -> Matrix4

Subtract two matrices

§Examples
use vex::Matrix4;
 
let a = Matrix4::make(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);
let b = Matrix4::make(16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
let actual = a - b;
let expected = Matrix4::make(-15.0, -13.0, -11.0, -9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0);
assert_eq!(actual, expected);
Source§

type Output = Matrix4

The resulting type after applying the - operator.
Source§

impl SubAssign<f32> for Matrix4

Source§

fn sub_assign(&mut self, _rhs: f32)

Decrement a matrix by a scalar

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual -= 1.0;
let expected = Matrix4::make(0.0, 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);
assert_eq!(actual, expected);
Source§

impl SubAssign for Matrix4

Source§

fn sub_assign(&mut self, _rhs: Matrix4)

Decrement a matrix by another matrix

§Examples
use vex::Matrix4;
 
let mut actual = Matrix4::make(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);
actual -= Matrix4::make(0.0, 2.0, 3.0, 4.0, 5.0, 5.0, 7.0, 8.0, 9.0, 10.0, 10.0, 12.0, 13.0, 14.0, 15.0, 15.0);
assert_eq!(actual, Matrix4::new());
Source§

impl Copy for Matrix4

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.