pub struct Transform3D { /* private fields */ }Expand description
A 3D transform with position, rotation (Euler angles in degrees), and scale.
The transform maintains a 4×4 TRS matrix (translate × rotate × scale). Call
calc_matrix after mutating to recompute it.
§Operations
| Category | Methods |
|---|---|
| Position — getter | pos |
| Position — absolute setter | set_pos_all, set_pos_x, set_pos_y, set_pos_z |
| Position — relative move | move_all, move_x, move_y, move_z |
| Rotation — getter | rot |
| Rotation — absolute setter | set_rot_all, set_rot_x, set_rot_y, set_rot_z |
| Rotation — relative add | rotate_all, rotate_x, rotate_y, rotate_z |
| Scale — getter | scale |
| Scale — absolute setter | set_scale_all, set_scale_same, set_scale_x, set_scale_y, set_scale_z |
| Scale — relative add | scale_all, scale_same, scale_x, scale_y, scale_z |
| Matrix | matrix, calc_matrix |
§Example
ⓘ
use optic_render::Transform3D;
let mut t = Transform3D::default();
t.set_pos_all(10.0, 0.0, 0.0);
t.rotate_y(90.0);
t.calc_matrix();Implementations§
Source§impl Transform3D
impl Transform3D
Sourcepub fn calc_matrix(&mut self)
pub fn calc_matrix(&mut self)
Recomputes the transformation matrix from the current pos/rot/scale.
Sourcepub fn set_pos_all(&mut self, x: f32, y: f32, z: f32)
pub fn set_pos_all(&mut self, x: f32, y: f32, z: f32)
Sets the position to (x, y, z).
Sourcepub fn rotate_all(&mut self, x: f32, y: f32, z: f32)
pub fn rotate_all(&mut self, x: f32, y: f32, z: f32)
Rotates by (x, y, z) degrees.
Sourcepub fn set_rot_all(&mut self, x: f32, y: f32, z: f32)
pub fn set_rot_all(&mut self, x: f32, y: f32, z: f32)
Sets the rotation to (x, y, z) degrees.
Sourcepub fn scale_same(&mut self, xyz: f32)
pub fn scale_same(&mut self, xyz: f32)
Adds xyz to all three scale components.
Sourcepub fn set_scale_all(&mut self, x: f32, y: f32, z: f32)
pub fn set_scale_all(&mut self, x: f32, y: f32, z: f32)
Sets the scale to (x, y, z).
Sourcepub fn set_scale_same(&mut self, xyz: f32)
pub fn set_scale_same(&mut self, xyz: f32)
Sets all three scale components to xyz.
Sourcepub fn set_scale_x(&mut self, x: f32)
pub fn set_scale_x(&mut self, x: f32)
Sets the scale X component.
Sourcepub fn set_scale_y(&mut self, y: f32)
pub fn set_scale_y(&mut self, y: f32)
Sets the scale Y component.
Sourcepub fn set_scale_z(&mut self, z: f32)
pub fn set_scale_z(&mut self, z: f32)
Sets the scale Z component.
Trait Implementations§
Source§impl Clone for Transform3D
impl Clone for Transform3D
Source§fn clone(&self) -> Transform3D
fn clone(&self) -> Transform3D
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transform3D
impl Debug for Transform3D
Auto Trait Implementations§
impl Freeze for Transform3D
impl RefUnwindSafe for Transform3D
impl Send for Transform3D
impl Sync for Transform3D
impl Unpin for Transform3D
impl UnsafeUnpin for Transform3D
impl UnwindSafe for Transform3D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().