Union Matrix

Source
#[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

Source

pub const ZERO: Self

All elements are zeros.

Source

pub const IDENTITY: Self

Identity matrix.

Source§

impl Matrix

Source

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.

Source

pub fn diagonal(diagonal: Vector) -> Self

Creates a diagonal matrix.

Source

pub const fn from_columns( x_axis: Vector, y_axis: Vector, z_axis: Vector, w_axis: Vector, ) -> Self

Creates with given column vectors.

Source

pub fn from_column_array(arr: [f32; 16]) -> Self

Creates from a given array.

Source

pub fn into_column_array(self) -> [f32; 16]

Stores the value in an array.

Source

pub fn from_column_slice(slice: &[f32]) -> Self

Creates from a given array of slice.

§Panics

When the use-assertion feature is enabled, it will panic! if the array slice has less than sixteen elements.

Source

pub fn load_float3x3(val: Float3x3) -> Self

Loads a value from a given Float4x4.

Source

pub fn store_float3x3(self) -> Float3x3

Stores the value in a Float4x4.

Source

pub fn load_float4x4(val: Float4x4) -> Self

Loads a value from a given Float4x4.

Source

pub fn store_float4x4(self) -> Float4x4

Stores the value in a Float4x4.

Source

pub fn from_translation(translation: Vector) -> Self

Create a matrix with the given translation.

Source

pub fn from_rotation_translation( rotation: Quaternion, translation: Vector, ) -> Self

Creates a matrix with the given rotation and translation.

※ The given rotation must be normalized.

§Panics

When the use-assertion feature is enabled, it will panic! if the given quaternion is not a normalized quaternion.

Source

pub fn from_scale_rotation_translation( scale: Vector, rotation: Quaternion, translation: Vector, ) -> Self

Creates a matrix with the given scale, rotation and translation.

※ The given rotation must be normalized.

§Panics

When the use-assertion feature is enabled, it will panic! if the given quaternion is not a normalized quaternion.

Source

pub fn from_rotation_x(angle: f32) -> Self

Creates a matrix rotated by a given x-axis angle.

※ The angles given are in radians.

Source

pub fn from_rotation_y(angle: f32) -> Self

Creates a matrix rotated by a given y-axis angle.

※ The angles given are in radians.

Source

pub fn from_rotation_z(angle: f32) -> Self

Creates a matrix rotated by a given z-axis angle.

※ The angles given are in radians.

Source

pub fn look_to_rh(eye: Vector, dir: Vector, up: Vector) -> Self

Create a right-handed coordinate view matrix with the given eye, dir, and up.

※ The given dir and up must be unit vectors.

§Panics

When the use-assertion feature is enabled, it will panic! if the given dir and up is not unit vectors.

Source

pub fn look_to_lh(eye: Vector, dir: Vector, up: Vector) -> Self

Create a left-handed coordinate view matrix with the given eye, dir, and up.

※ The given dir and up must be unit vectors.

§Panics

When the use-assertion feature is enabled, it will panic! if the given dir and up is not unit vectors.

Source

pub fn look_at_rh(eye: Vector, at: Vector, up: Vector) -> Self

Create a right-handed coordinate view matrix with the given eye, at, and up.

※ The given position of eye and at must be different.

§Panics

When the use-assertion feature is enabled, it will panic! if the given eye and at are equal.

Source

pub fn look_at_lh(eye: Vector, at: Vector, up: Vector) -> Self

Create a left-handed coordinate view matrix with the given eye, at, and up.

※ The given position of eye and at must be different.

§Panics

When the use-assertion feature is enabled, it will panic! if the given eye and at are equal.

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn get_x_axis(&self) -> &Vector

Get the x-axis of a matrix.

Source

pub fn set_x_axis(&mut self, v: Vector)

Set the x-axis of a matrix.

Source

pub fn get_y_axis(&self) -> &Vector

Get the y-axis of a matrix.

Source

pub fn set_y_axis(&mut self, v: Vector)

Set the y-axis of a matrix.

Source

pub fn get_z_axis(&self) -> &Vector

Get the z-axis of a matrix.

Source

pub fn set_z_axis(&mut self, v: Vector)

Set the z-axis of a matrix.

Source

pub fn get_w_axis(&self) -> &Vector

Get the w-axis of a matrix.

Source

pub fn set_w_axis(&mut self, v: Vector)

Set the x-axis of a matrix.

Source

pub fn transpose(self) -> Self

Transpose of a matrix.

Source

pub fn determinant(self) -> Vector

Determinant of a matrix.

Source

pub fn determinant_into(self) -> f32

Determinant of a matrix.

Source

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.

Source

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 Add for Matrix

Source§

fn add(self, rhs: Self) -> Self::Output

Adds two matrices.

Source§

type Output = Matrix

The resulting type after applying the + operator.
Source§

impl AddAssign for Matrix

Source§

fn add_assign(&mut self, rhs: Self)

Adds two matrices. (assign)

Source§

impl Clone for Matrix

Source§

fn clone(&self) -> Matrix

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 Matrix

Source§

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

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

impl Default for Matrix

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<[f32; 16]> for Matrix

Source§

fn from(value: [f32; 16]) -> Self

Converts to this type from the input type.
Source§

impl From<Float3x3> for Matrix

Source§

fn from(value: Float3x3) -> Self

Converts to this type from the input type.
Source§

impl From<Float4x4> for Matrix

Source§

fn from(value: Float4x4) -> Self

Converts to this type from the input type.
Source§

impl Into<[f32; 16]> for Matrix

Source§

fn into(self) -> [f32; 16]

Converts this type into the (usually inferred) input type.
Source§

impl Into<Float3x3> for Matrix

Source§

fn into(self) -> Float3x3

Converts this type into the (usually inferred) input type.
Source§

impl Into<Float4x4> for Matrix

Source§

fn into(self) -> Float4x4

Converts this type into the (usually inferred) input type.
Source§

impl Mul<Matrix> for f32

Source§

fn mul(self, rhs: Matrix) -> Self::Output

Multiplies each element of a matrix by a scalar value.

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

impl Mul<Vector> for Matrix

Source§

fn mul(self, rhs: Vector) -> Self::Output

Transformation of the vector.

Source§

type Output = Vector

The resulting type after applying the * operator.
Source§

impl Mul<f32> for Matrix

Source§

fn mul(self, rhs: f32) -> Self::Output

Multiplies each element of a matrix by a scalar value.

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

impl Mul for Matrix

Source§

fn mul(self, rhs: Self) -> Self::Output

Multiplies two matrices.

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

impl MulAssign for Matrix

Source§

fn mul_assign(&mut self, rhs: Self)

Multiplies two matrices. (assign)

Source§

impl Neg for Matrix

Source§

fn neg(self) -> Self::Output

Nagative.

Source§

type Output = Matrix

The resulting type after applying the - operator.
Source§

impl Sub for Matrix

Source§

fn sub(self, rhs: Self) -> Self::Output

Subtracts two matrices.

Source§

type Output = Matrix

The resulting type after applying the - operator.
Source§

impl SubAssign for Matrix

Source§

fn sub_assign(&mut self, rhs: Self)

Subtracts two matrices. (assign)

Source§

impl Copy for Matrix

Auto Trait Implementations§

§

impl Freeze for Matrix

§

impl RefUnwindSafe for Matrix

§

impl Send for Matrix

§

impl Sync for Matrix

§

impl Unpin for Matrix

§

impl UnwindSafe for Matrix

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, 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.