pub struct Matrix4(/* private fields */);
Expand description
A 4x4 row-major matrix of f32
s.
§Layout details
Rows are actually stored as WZYX in memory. There are helper functions
for accessing the rows in XYZW form. The Debug
implementation prints
the shows in WZYX form
It is also guaranteed to have the same layout as citro3d_sys::C3D_Mtx
Implementations§
source§impl Matrix4
impl Matrix4
sourcepub fn from_cells_wzyx(cells: [f32; 16]) -> Self
pub fn from_cells_wzyx(cells: [f32; 16]) -> Self
pub fn as_raw(&self) -> &C3D_Mtx
pub fn as_raw_mut(&mut self) -> &mut C3D_Mtx
pub fn into_raw(self) -> C3D_Mtx
sourcepub fn translate(&mut self, x: f32, y: f32, z: f32)
pub fn translate(&mut self, x: f32, y: f32, z: f32)
Translate a transformation matrix by the given amounts in the X, Y, and Z directions.
sourcepub fn scale(&mut self, x: f32, y: f32, z: f32)
pub fn scale(&mut self, x: f32, y: f32, z: f32)
Scale a transformation matrix by the given amounts in the X, Y, and Z directions.
sourcepub fn rotate(&mut self, axis: FVec3, angle: f32)
pub fn rotate(&mut self, axis: FVec3, angle: f32)
Rotate a transformation matrix by the given angle around the given axis.
sourcepub fn rotate_x(&mut self, angle: f32)
pub fn rotate_x(&mut self, angle: f32)
Rotate a transformation matrix by the given angle around the X axis.
sourcepub fn rotate_y(&mut self, angle: f32)
pub fn rotate_y(&mut self, angle: f32)
Rotate a transformation matrix by the given angle around the Y axis.
sourcepub fn rotate_z(&mut self, angle: f32)
pub fn rotate_z(&mut self, angle: f32)
Rotate a transformation matrix by the given angle around the Z axis.
sourcepub fn inverse(self) -> Result<Self, Self>
pub fn inverse(self) -> Result<Self, Self>
Find the inverse of the matrix.
§Errors
If the matrix has no inverse, it will be returned unchanged as an [Err
].
sourcepub fn diagonal(x: f32, y: f32, z: f32, w: f32) -> Self
pub fn diagonal(x: f32, y: f32, z: f32, w: f32) -> Self
Construct a 4x4 matrix with the given values on the diagonal.
sourcepub fn looking_at(
camera_position: FVec3,
camera_target: FVec3,
camera_up: FVec3,
coordinates: CoordinateOrientation
) -> Self
pub fn looking_at( camera_position: FVec3, camera_target: FVec3, camera_up: FVec3, coordinates: CoordinateOrientation ) -> Self
Construct a 3D transformation matrix for a camera, given its position, target, and upward direction.