pub struct Transform3D { /* private fields */ }Expand description
A full 3D transformation stored as a 4×4 matrix.
Backed by glam::Mat4 which provides SIMD-optimized operations.
Needed for perspective transforms, 3D rotations, and compositing
layers that exist in 3D space.
For pure 2D work, prefer AffineTransform — it uses fewer
operations and less memory.
Implementations§
Source§impl Transform3D
impl Transform3D
pub const IDENTITY: Self
pub fn translate(tx: f32, ty: f32, tz: f32) -> Self
pub fn scale(sx: f32, sy: f32, sz: f32) -> Self
pub fn rotate_x(angle: f32) -> Self
pub fn rotate_y(angle: f32) -> Self
Sourcepub fn perspective(depth: f32) -> Self
pub fn perspective(depth: f32) -> Self
A perspective projection that makes distant objects appear smaller.
depth is the distance from the viewer to the z=0 plane.
pub fn is_identity(&self) -> bool
Sourcepub fn is_2d(&self) -> bool
pub fn is_2d(&self) -> bool
True when the transform operates only in the X/Y plane (no Z
rotation, no perspective, no Z translation). Can be losslessly
represented as an AffineTransform.
Sourcepub fn to_affine(&self) -> AffineTransform
pub fn to_affine(&self) -> AffineTransform
Extract a 2D affine transform, dropping the Z components.
Only meaningful when is_2d returns true.
Sourcepub fn from_affine(t: &AffineTransform) -> Self
pub fn from_affine(t: &AffineTransform) -> Self
Promote a 2D affine transform to a 3D matrix.
pub fn then(&self, other: &Self) -> Self
Sourcepub fn inverse(&self) -> Option<Self>
pub fn inverse(&self) -> Option<Self>
Compute the inverse. Returns None if the matrix is singular.
pub fn determinant(&self) -> f32
Sourcepub fn transform_point(&self, p: Point) -> Point
pub fn transform_point(&self, p: Point) -> Point
Transform a 2D point through this 3D matrix. The point is treated
as (x, y, 0, 1) and projected back to 2D by dividing by the
homogeneous w coordinate.
Sourcepub fn is_back_face_visible(&self) -> bool
pub fn is_back_face_visible(&self) -> bool
True when the back face of a transformed plane would be visible (the Z component of the transformed normal is negative).
Trait Implementations§
Source§impl Clone for Transform3D
impl Clone for Transform3D
Source§fn clone(&self) -> Transform3D
fn clone(&self) -> Transform3D
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more