[][src]Struct ezcgmath::matrix::Matrix4x4

#[repr(C)]pub struct Matrix4x4 {
    pub c00: Scalar,
    pub c10: Scalar,
    pub c20: Scalar,
    pub c30: Scalar,
    pub c01: Scalar,
    pub c11: Scalar,
    pub c21: Scalar,
    pub c31: Scalar,
    pub c02: Scalar,
    pub c12: Scalar,
    pub c22: Scalar,
    pub c32: Scalar,
    pub c03: Scalar,
    pub c13: Scalar,
    pub c23: Scalar,
    pub c33: Scalar,
}

A 4 x 4 Matrix.

Fields

c00: Scalarc10: Scalarc20: Scalarc30: Scalarc01: Scalarc11: Scalarc21: Scalarc31: Scalarc02: Scalarc12: Scalarc22: Scalarc32: Scalarc03: Scalarc13: Scalarc23: Scalarc33: Scalar

Implementations

impl Matrix4x4[src]

pub const fn identity() -> Self[src]

pub fn new_perspective_projection(
    fov: Degrees,
    aspect_ratio: Scalar,
    near_plane: Scalar,
    far_plane: Scalar
) -> Self
[src]

Constructs a new perspective projection. As a reminder, this will create a left-handed perspective matrix. If you require a right-handed coordinate system, you'll have to convert to it with with a reflection matrix.

The parameters follow convention as far as I am aware, but to clarify:

  • fovy corresponds to the width of the field of view visible (or how far out you can hold your arms).
  • aspect ratio is the ratio of width to height for the screen (so aspect_ratio = screen_width / screen_height).
  • near_plane defines the start of the clipping volume for the camera along the z (the minimum distance at which objects can be rendered).
  • far_plane defines the end of the clipping volume for the camera along the z (the maximum distance at which objects can be rendered).

pub fn new_orthographic_projection(
    top: Scalar,
    bottom: Scalar,
    left: Scalar,
    right: Scalar,
    near_plane: Scalar,
    far_plane: Scalar
) -> Self
[src]

Constructs a new orthographic projection. As a reminder, this will create a left-handed orthographic matrix. If you require a right-handed coordinate system, you'll have to convert to it with with a reflection matrix.

I opted for simple parameters for this method, so you can create any size or shape orthographic bounding volume you desire. However, my advice would be for your code to define an orthographic_size variable somehow. You can then convert to top/bottom/left/right as follows:

struct OrthoBounds {
    top: f32,
    bottom: f32,
    left: f32,
    right: f32,
}

fn get_ortho_bounds(orthographic_size: f32, aspect_ratio: f32) -> OrthoBounds {
    OrthoBounds {
        top: 0.5 * orthographic_size,
        bottom: -0.5 * orthographic_size,
        left: -0.5 * orthographic_size * aspect_ratio,
        right: 0.5 * orthographic_size * aspect_ratio,
    }
}

If you choose not to use the above method, bear in mind that top - bottom and right - left should never equal 0. This will cause a panic.

pub const fn from_translation(translation: &Vector3) -> Self[src]

Creates a translation matrix from a Vector3.

pub const fn from_nonuniform_scale(scale: &Vector3) -> Self[src]

Creates a non-uniform scaling matrix from a Vector3.

pub const fn from_scale(scale: Scalar) -> Self[src]

Creates a uniform scaling matrix from a Scalar.

pub fn matrix_of_minors(&self) -> Matrix4x4[src]

Compiles a matrix of minors for this matrix.

pub fn matrix_of_cofactors(&self) -> Matrix4x4[src]

Compiles a matrix of cofactors for this matrix.

pub fn transpose(&self) -> Matrix4x4[src]

Returns a new matrix with the elements transposed.

pub fn determinant(&self) -> f32[src]

Calculates the determinant for this matrix.

pub fn inverse(&self) -> Matrix4x4[src]

Calculates the Inverse matrix for this matrix.

Trait Implementations

impl AbsDiffEq<Matrix4x4> for Matrix4x4[src]

type Epsilon = Scalar

Used for specifying relative comparisons.

impl Add<Matrix4x4> for Matrix4x4[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Matrix4x4> for Matrix4x4[src]

impl Clone for Matrix4x4[src]

impl Copy for Matrix4x4[src]

impl Debug for Matrix4x4[src]

impl Default for Matrix4x4[src]

impl From<Quaternion> for Matrix4x4[src]

impl Mul<Matrix4x4> for Matrix4x4[src]

type Output = Matrix4x4

The resulting type after applying the * operator.

impl Mul<Matrix4x4> for Quaternion[src]

type Output = Matrix4x4

The resulting type after applying the * operator.

impl Mul<Matrix4x4> for Vector3[src]

type Output = Vector3

The resulting type after applying the * operator.

impl Mul<Matrix4x4> for Vector4[src]

type Output = Vector4

The resulting type after applying the * operator.

impl Mul<Quaternion> for Matrix4x4[src]

type Output = Matrix4x4

The resulting type after applying the * operator.

impl Mul<f32> for Matrix4x4[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<Matrix4x4> for Matrix4x4[src]

impl MulAssign<Matrix4x4> for Vector3[src]

impl MulAssign<Matrix4x4> for Vector4[src]

impl MulAssign<Quaternion> for Matrix4x4[src]

impl MulAssign<f32> for Matrix4x4[src]

impl PartialEq<Matrix4x4> for Matrix4x4[src]

impl RelativeEq<Matrix4x4> for Matrix4x4[src]

impl StructuralPartialEq for Matrix4x4[src]

impl Sub<Matrix4x4> for Matrix4x4[src]

type Output = Self

The resulting type after applying the - operator.

impl SubAssign<Matrix4x4> for Matrix4x4[src]

impl UlpsEq<Matrix4x4> for Matrix4x4[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.