Skip to main content

Transform3D

Struct Transform3D 

Source
pub struct Transform3D { /* private fields */ }
Expand description

3D world-space transform (translation, yaw/pitch/roll Euler rotation, and non-uniform scale).

Implementations§

Source§

impl Transform3D

Matrix and point transformation helpers for Transform3D.

Source

pub const fn new(position: Vec3, yaw_rad: f32, scale: Vec3) -> Self

Constructs a Transform3D from position, Y-axis yaw, and non-uniform scale.

§Arguments
  • Vec3 - World-space translation.
  • f32 - Horizontal Y-axis yaw rotation in radians.
  • Vec3 - Non-uniform scale.
§Returns
  • Self - Constructed 3D transform.
Source

pub fn with_euler(self, yaw_rad: f32, pitch_rad: f32, roll_rad: f32) -> Self

Returns a copy of this transform with full yaw, pitch, and roll Euler rotation in radians.

§Arguments
  • Self - Source transform.
  • f32 - Y-axis yaw in radians.
  • f32 - X-axis pitch in radians.
  • f32 - Z-axis roll in radians.
§Returns
  • Self - Rotated 3D transform.
Source

pub fn lerp(self, other: Self, t: f32) -> Self

Linearly interpolates position, Euler angles, and scale between self and other.

§Arguments
  • Self - Start transform.
  • Self - End transform.
  • f32 - Interpolation factor in [0.0, 1.0].
§Returns
  • Self - Interpolated transform.
Source

pub fn lerp_shortest_angle(self, other: Self, t: f32) -> Self

Interpolates position, scale, and shortest-arc Euler angles between self and other for render-time snapshot blending.

§Arguments
  • Self - Previous fixed-step transform.
  • Self - Current fixed-step transform.
  • f32 - Normalized interpolation factor in [0.0, 1.0].
§Returns
  • Self - Shortest-arc interpolated transform.
Source

pub fn to_mat4(&self) -> Mat4

Converts this TRS transform into a column-major Mat4.

§Arguments
  • &Self - Transform reference.
§Returns
  • Mat4 - Model matrix.
Source

pub fn transform_point(&self, p: Vec3) -> Vec3

Transforms a local-space 3D point into world space.

§Arguments
  • &Self - Transform reference.
  • Vec3 - Local-space point.
§Returns
  • Vec3 - World-space point.
Source

pub fn transform_normal(&self, n: Vec3) -> Vec3

Rotates a local-space surface normal into world space.

§Arguments
  • &Self - Transform reference.
  • Vec3 - Local normal.
§Returns
  • Vec3 - World-space unit normal.
Source

pub fn transform_aabb(&self, local: Aabb3D) -> Aabb3D

Transforms a local Aabb3D into an enclosing world-space Aabb3D.

§Arguments
  • &Self - Transform reference.
  • Aabb3D - Local bounding box.
§Returns
  • Aabb3D - Enclosing world-space bounding box.
Source§

impl Transform3D

Source

pub fn get_position(&self) -> Vec3

Source

pub fn get_mut_position(&mut self) -> &mut Vec3

Source

pub fn set_position(&mut self, val: Vec3) -> &mut Self

Source

pub fn get_yaw_rad(&self) -> f32

Source

pub fn get_mut_yaw_rad(&mut self) -> &mut f32

Source

pub fn set_yaw_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_pitch_rad(&self) -> f32

Source

pub fn get_mut_pitch_rad(&mut self) -> &mut f32

Source

pub fn set_pitch_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_roll_rad(&self) -> f32

Source

pub fn get_mut_roll_rad(&mut self) -> &mut f32

Source

pub fn set_roll_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_scale(&self) -> Vec3

Source

pub fn get_mut_scale(&mut self) -> &mut Vec3

Source

pub fn set_scale(&mut self, val: Vec3) -> &mut Self

Trait Implementations§

Source§

impl Clone for Transform3D

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Transform3D

Source§

impl Debug for Transform3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transform3D

Default identity Transform3D.

Source§

fn default() -> Self

Returns identity transform at origin with unit scale.

§Returns
  • Self - Identity Transform3D.
Source§

impl PartialEq for Transform3D

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transform3D

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.