Module transforms

Module transforms 

Source
Expand description

3D transformation functions for computer graphics.

This module provides functions to create and manipulate transformation matrices commonly used in 3D graphics, including translation, rotation, scaling, and projection matrices.

§Examples

use rs_math3d::transforms;
use rs_math3d::vector::Vector3;
 
// Create a translation matrix
let translation = transforms::translate(Vector3::new(10.0, 5.0, 0.0));
 
// Create a perspective projection matrix
let projection = transforms::perspective(
    45.0f32.to_radians(),  // Field of view
    16.0 / 9.0,            // Aspect ratio
    0.1,                   // Near plane
    100.0                  // Far plane
);

Functions§

decompose
Decomposes a transformation matrix into scale, rotation, and translation.
frustum
Creates a perspective projection matrix from frustum bounds.
lookat
Creates a view matrix looking from eye position to target.
ortho4
Creates an orthographic projection matrix.
perspective
Creates a perspective projection matrix.
project3
Projects a 3D point to screen coordinates.
rotation_from_axis_angle
Creates a 4x4 rotation matrix from an axis and angle.
rotation_from_quat
Creates a 4x4 rotation matrix from a quaternion.
scale
Creates a 4x4 scaling matrix.
transform_vec3
Transforms a 3D vector by a 4x4 matrix with perspective division.
translate
Creates a 4x4 translation matrix.
unproject3
Unprojects screen coordinates back to 3D world space.