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>
impl<T: RealField> Matrix4<T>
§3D transformations as a Matrix4
sourcepub fn new_rotation(axisangle: Vector3<T>) -> Self
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.
sourcepub fn new_rotation_wrt_point(axisangle: Vector3<T>, pt: Point3<T>) -> Self
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.
sourcepub fn new_nonuniform_scaling_wrt_point(
scaling: &Vector3<T>,
pt: &Point3<T>
) -> Self
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.
sourcepub fn from_scaled_axis(axisangle: Vector3<T>) -> Self
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
.
sourcepub fn from_euler_angles(roll: T, pitch: T, yaw: T) -> Self
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.
sourcepub fn from_axis_angle(axis: &Unit<Vector3<T>>, angle: T) -> Self
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.
sourcepub fn new_orthographic(
left: T,
right: T,
bottom: T,
top: T,
znear: T,
zfar: T
) -> Self
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.
sourcepub fn new_perspective(aspect: T, fovy: T, znear: T, zfar: T) -> Self
pub fn new_perspective(aspect: T, fovy: T, znear: T, zfar: T) -> Self
Creates a new homogeneous matrix for a perspective projection.
sourcepub fn face_towards(
eye: &Point3<T>,
target: &Point3<T>,
up: &Vector3<T>
) -> Self
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
.
sourcepub fn new_observer_frame(
eye: &Point3<T>,
target: &Point3<T>,
up: &Vector3<T>
) -> Self
👎Deprecated: renamed to face_towards
pub fn new_observer_frame( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T> ) -> Self
face_towards
Deprecated: Use Matrix4::face_towards
instead.
sourcepub fn look_at_rh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
pub fn look_at_rh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
Builds a right-handed look-at view matrix.
sourcepub fn look_at_lh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
pub fn look_at_lh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
Builds a left-handed look-at view matrix.