#[repr(C)]
pub union Matrix {
/* private fields */
}
Expand description
This is a matrix data type that uses the SIMD
instruction.
Using the sse2
instruction.
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn new(
m00: f32,
m01: f32,
m02: f32,
m03: f32,
m10: f32,
m11: f32,
m12: f32,
m13: f32,
m20: f32,
m21: f32,
m22: f32,
m23: f32,
m30: f32,
m31: f32,
m32: f32,
m33: f32,
) -> Self
pub fn new( m00: f32, m01: f32, m02: f32, m03: f32, m10: f32, m11: f32, m12: f32, m13: f32, m20: f32, m21: f32, m22: f32, m23: f32, m30: f32, m31: f32, m32: f32, m33: f32, ) -> Self
Creates with given elements.
Sourcepub const fn from_columns(
x_axis: Vector,
y_axis: Vector,
z_axis: Vector,
w_axis: Vector,
) -> Self
pub const fn from_columns( x_axis: Vector, y_axis: Vector, z_axis: Vector, w_axis: Vector, ) -> Self
Creates with given column vectors.
Sourcepub fn from_column_array(arr: [f32; 16]) -> Self
pub fn from_column_array(arr: [f32; 16]) -> Self
Creates from a given array.
Sourcepub fn into_column_array(self) -> [f32; 16]
pub fn into_column_array(self) -> [f32; 16]
Stores the value in an array.
Sourcepub fn from_column_slice(slice: &[f32]) -> Self
pub fn from_column_slice(slice: &[f32]) -> Self
Sourcepub fn load_float3x3(val: Float3x3) -> Self
pub fn load_float3x3(val: Float3x3) -> Self
Loads a value from a given Float4x4
.
Sourcepub fn store_float3x3(self) -> Float3x3
pub fn store_float3x3(self) -> Float3x3
Stores the value in a Float4x4
.
Sourcepub fn load_float4x4(val: Float4x4) -> Self
pub fn load_float4x4(val: Float4x4) -> Self
Loads a value from a given Float4x4
.
Sourcepub fn store_float4x4(self) -> Float4x4
pub fn store_float4x4(self) -> Float4x4
Stores the value in a Float4x4
.
Sourcepub fn from_translation(translation: Vector) -> Self
pub fn from_translation(translation: Vector) -> Self
Create a matrix with the given translation
.
Sourcepub fn from_rotation_translation(
rotation: Quaternion,
translation: Vector,
) -> Self
pub fn from_rotation_translation( rotation: Quaternion, translation: Vector, ) -> Self
Sourcepub fn from_scale_rotation_translation(
scale: Vector,
rotation: Quaternion,
translation: Vector,
) -> Self
pub fn from_scale_rotation_translation( scale: Vector, rotation: Quaternion, translation: Vector, ) -> Self
Sourcepub fn from_rotation_x(angle: f32) -> Self
pub fn from_rotation_x(angle: f32) -> Self
Creates a matrix rotated by a given x-axis angle.
※ The angles given are in radians.
Sourcepub fn from_rotation_y(angle: f32) -> Self
pub fn from_rotation_y(angle: f32) -> Self
Creates a matrix rotated by a given y-axis angle.
※ The angles given are in radians.
Sourcepub fn from_rotation_z(angle: f32) -> Self
pub fn from_rotation_z(angle: f32) -> Self
Creates a matrix rotated by a given z-axis angle.
※ The angles given are in radians.
Sourcepub fn look_to_rh(eye: Vector, dir: Vector, up: Vector) -> Self
pub fn look_to_rh(eye: Vector, dir: Vector, up: Vector) -> Self
Sourcepub fn look_to_lh(eye: Vector, dir: Vector, up: Vector) -> Self
pub fn look_to_lh(eye: Vector, dir: Vector, up: Vector) -> Self
Sourcepub fn look_at_rh(eye: Vector, at: Vector, up: Vector) -> Self
pub fn look_at_rh(eye: Vector, at: Vector, up: Vector) -> Self
Sourcepub fn look_at_lh(eye: Vector, at: Vector, up: Vector) -> Self
pub fn look_at_lh(eye: Vector, at: Vector, up: Vector) -> Self
Sourcepub fn perspective_rh(
fov_y: f32,
aspect_ratio: f32,
z_near: f32,
z_far: f32,
) -> Self
pub fn perspective_rh( fov_y: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Self
Create a right-handed coordinate perspective projection matrix
with the given fov_y
, aspect_ratio
, z_near
, z_far
.
※ The depth of the created frustum ranges from 0.0
to 1.0
.
※ The given fov_y
is in radians.
※ The given value of z_near
and z_far
must be different.
§Panics
When the use-assertion
feature is enabled, it will panic!
if the given z_near
and z_far
are equal.
Sourcepub fn perspective_lh(
fov_y: f32,
aspect_ratio: f32,
z_near: f32,
z_far: f32,
) -> Self
pub fn perspective_lh( fov_y: f32, aspect_ratio: f32, z_near: f32, z_far: f32, ) -> Self
Create a left-handed coordinate perspective projection matrix
with the given fov_y
, aspect_ratio
, z_near
, z_far
.
※ The depth of the created frustum ranges from 0.0
to 1.0
.
※ The given fov_y
is in radians.
※ The given value of z_near
and z_far
must be different.
§Panics
When the use-assertion
feature is enabled, it will panic!
if the given z_near
and z_far
are equal.
Sourcepub fn orthographic_rh(
left: f32,
right: f32,
bottom: f32,
top: f32,
near: f32,
far: f32,
) -> Self
pub fn orthographic_rh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Self
Create a right-handed coordinate orthographic projection matrix
with the given left
, right
, bottom
, top
, near
, far
.
※ The depth of the created frustum ranges from 0.0
to 1.0
.
※ The given value of left
and right
must be different.
※ The given value of bottom
and top
must be different.
※ The given value of near
and far
must be different.
§Panics
When the use-assertion
feature is enabled, it will panic!
if the given left
and right
are equal
or bottom
and top
are equal
or near
and far
are equal.
Sourcepub fn orthographic_lh(
left: f32,
right: f32,
bottom: f32,
top: f32,
near: f32,
far: f32,
) -> Self
pub fn orthographic_lh( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Self
Create a left-handed coordinate orthographic projection matrix
with the given left
, right
, bottom
, top
, near
, far
.
※ The depth of the created frustum ranges from 0.0
to 1.0
.
※ The given value of left
and right
must be different.
※ The given value of bottom
and top
must be different.
※ The given value of near
and far
must be different.
§Panics
When the use-assertion
feature is enabled, it will panic!
if the given left
and right
are equal
or bottom
and top
are equal
or near
and far
are equal.
Source§impl Matrix
impl Matrix
Sourcepub fn get_x_axis(&self) -> &Vector
pub fn get_x_axis(&self) -> &Vector
Get the x-axis of a matrix.
Sourcepub fn set_x_axis(&mut self, v: Vector)
pub fn set_x_axis(&mut self, v: Vector)
Set the x-axis of a matrix.
Sourcepub fn get_y_axis(&self) -> &Vector
pub fn get_y_axis(&self) -> &Vector
Get the y-axis of a matrix.
Sourcepub fn set_y_axis(&mut self, v: Vector)
pub fn set_y_axis(&mut self, v: Vector)
Set the y-axis of a matrix.
Sourcepub fn get_z_axis(&self) -> &Vector
pub fn get_z_axis(&self) -> &Vector
Get the z-axis of a matrix.
Sourcepub fn set_z_axis(&mut self, v: Vector)
pub fn set_z_axis(&mut self, v: Vector)
Set the z-axis of a matrix.
Sourcepub fn get_w_axis(&self) -> &Vector
pub fn get_w_axis(&self) -> &Vector
Get the w-axis of a matrix.
Sourcepub fn set_w_axis(&mut self, v: Vector)
pub fn set_w_axis(&mut self, v: Vector)
Set the x-axis of a matrix.
Sourcepub fn determinant(self) -> Vector
pub fn determinant(self) -> Vector
Determinant of a matrix.
Sourcepub fn determinant_into(self) -> f32
pub fn determinant_into(self) -> f32
Determinant of a matrix.
Sourcepub fn inverse(self) -> Self
pub fn inverse(self) -> Self
Inverse of a matrix.
§Panics
When the use-assertion
feature is enabled, it will panic!
if the determinant of a matrix is less than or equal to f32::EPSILON
.
Sourcepub fn try_inverse(self) -> Option<Self>
pub fn try_inverse(self) -> Option<Self>
Inverse of a matrix.
Returns None
if the determinant of a matrix is less than or equal to f32::EPSILON
.
Trait Implementations§
Source§impl AddAssign for Matrix
impl AddAssign for Matrix
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Adds two matrices. (assign)
Source§impl MulAssign for Matrix
impl MulAssign for Matrix
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Multiplies two matrices. (assign)
Source§impl SubAssign for Matrix
impl SubAssign for Matrix
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Subtracts two matrices. (assign)