nalgebra::base

Type Alias Matrix4

Source
pub type Matrix4<T> = Matrix<T, U4, U4, ArrayStorage<T, 4, 4>>;
Expand description

A stack-allocated, column-major, 4x4 square matrix.

Because this is an alias, not all its methods are listed here. See the Matrix type too.

Aliased Type§

struct Matrix4<T> {
    pub data: ArrayStorage<T, 4, 4>,
    /* private fields */
}

Fields§

§data: ArrayStorage<T, 4, 4>

The data storage that contains all the matrix components. Disappointed?

Well, if you came here to see how you can access the matrix components, you may be in luck: you can access the individual components of all vectors with compile-time dimensions <= 6 using field notation like this: vec.x, vec.y, vec.z, vec.w, vec.a, vec.b. Reference and assignation work too:

let mut vec = Vector3::new(1.0, 2.0, 3.0);
vec.x = 10.0;
vec.y += 30.0;
assert_eq!(vec.x, 10.0);
assert_eq!(vec.y + 100.0, 132.0);

Similarly, for matrices with compile-time dimensions <= 6, you can use field notation like this: mat.m11, mat.m42, etc. The first digit identifies the row to address and the second digit identifies the column to address. So mat.m13 identifies the component at the first row and third column (note that the count of rows and columns start at 1 instead of 0 here. This is so we match the mathematical notation).

For all matrices and vectors, independently from their size, individual components can be accessed and modified using indexing: vec[20], mat[(20, 19)]. Here the indexing starts at 0 as you would expect.

Implementations§

Source§

impl<T: RealField> Matrix4<T>

§3D transformations as a Matrix4

Source

pub fn new_rotation(axisangle: Vector3<T>) -> Self

Builds a 3D homogeneous rotation matrix from an axis and an angle (multiplied together).

Returns the identity matrix if the given argument is zero.

Source

pub fn new_rotation_wrt_point(axisangle: Vector3<T>, pt: Point3<T>) -> Self

Builds a 3D homogeneous rotation matrix from an axis and an angle (multiplied together).

Returns the identity matrix if the given argument is zero.

Source

pub fn new_nonuniform_scaling_wrt_point( scaling: &Vector3<T>, pt: &Point3<T>, ) -> Self

Creates a new homogeneous matrix that applies a scaling factor for each dimension with respect to point.

Can be used to implement zoom_to functionality.

Source

pub fn from_scaled_axis(axisangle: Vector3<T>) -> Self

Builds a 3D homogeneous rotation matrix from an axis and an angle (multiplied together).

Returns the identity matrix if the given argument is zero. This is identical to Self::new_rotation.

Source

pub fn from_euler_angles(roll: T, pitch: T, yaw: T) -> Self

Creates a new rotation from Euler angles.

The primitive rotations are applied in order: 1 roll − 2 pitch − 3 yaw.

Source

pub fn from_axis_angle(axis: &Unit<Vector3<T>>, angle: T) -> Self

Builds a 3D homogeneous rotation matrix from an axis and a rotation angle.

Source

pub fn new_orthographic( left: T, right: T, bottom: T, top: T, znear: T, zfar: T, ) -> Self

Creates a new homogeneous matrix for an orthographic projection.

Source

pub fn new_perspective(aspect: T, fovy: T, znear: T, zfar: T) -> Self

Creates a new homogeneous matrix for a perspective projection.

Source

pub fn face_towards( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>, ) -> Self

Creates an isometry that corresponds to the local frame of an observer standing at the point eye and looking toward target.

It maps the view direction target - eye to the positive z axis and the origin to the eye.

Source

pub fn new_observer_frame( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>, ) -> Self

👎Deprecated: renamed to face_towards

Deprecated: Use Matrix4::face_towards instead.

Source

pub fn look_at_rh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self

Builds a right-handed look-at view matrix.

Source

pub fn look_at_lh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self

Builds a left-handed look-at view matrix.

Trait Implementations§

Source§

impl From<DMat4> for Matrix4<f64>

Source§

fn from(e: DMat4) -> Matrix4<f64>

Converts to this type from the input type.
Source§

impl From<Mat4> for Matrix4<f32>

Source§

fn from(e: Mat4) -> Matrix4<f32>

Converts to this type from the input type.
Source§

impl<T: RealField> From<Orthographic3<T>> for Matrix4<T>

Source§

fn from(orth: Orthographic3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: RealField> From<Perspective3<T>> for Matrix4<T>

Source§

fn from(pers: Perspective3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: RealField> From<Rotation<T, 3>> for Matrix4<T>

Source§

fn from(q: Rotation3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: SimdRealField + RealField> From<Unit<DualQuaternion<T>>> for Matrix4<T>

Source§

fn from(dq: UnitDualQuaternion<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: SimdRealField> From<Unit<Quaternion<T>>> for Matrix4<T>

Source§

fn from(q: UnitQuaternion<T>) -> Self

Converts to this type from the input type.