Skip to main content

Placement

Struct Placement 

Source
pub struct Placement {
    pub rotation: [[f64; 3]; 3],
    pub translation: [f64; 3],
    pub scale: [f64; 3],
}
Expand description

A transform from a mesh’s points to the world: world = rotation * (scale * p) + translation, where p is the mesh’s own point (its origin plus a local position), all in f64.

rotation is row-major and must be a proper rotation (orthonormal, determinant +1, within 1e-6 per entry, the same rule as Rigid::validate). scale is per axis, applied before the rotation, and must be finite and positive: zero would collapse the mesh (no inverse) and a negative one would mirror it (flipping winding, culling and signs). Placements are stored exactly as given.

Fields§

§rotation: [[f64; 3]; 3]

The rotation, row-major, applied after the scale.

§translation: [f64; 3]

The translation, applied after the rotation.

§scale: [f64; 3]

The per-axis scale, applied first. [1, 1, 1] leaves the mesh rigid.

Implementations§

Source§

impl Placement

Source

pub const IDENTITY: Placement

The placement that leaves the mesh where its coordinates say.

Source

pub fn validate(&self) -> Result<()>

Checks that the rotation is a proper rotation, and that the translation and the scale are finite with every scale component positive.

§Errors

SceneError::InvalidInput otherwise.

Source

pub fn is_scaled(&self) -> bool

Whether the placement scales: any component differs from 1.

Source

pub fn uniform_scale(&self) -> Option<f64>

The uniform scale when every component is equal, None otherwise.

Source

pub fn apply(&self, p: [f64; 3]) -> [f64; 3]

Maps a point of the mesh to the world: rotation * (scale * p) + translation.

Source

pub fn inverse_apply(&self, q: [f64; 3]) -> [f64; 3]

Maps a world point back to the mesh: (scale⁻¹ * rotationᵀ) * (q - translation).

Source

pub fn apply_direction(&self, d: [f64; 3]) -> [f64; 3]

Maps a mesh-local direction to the world: rotation * (scale * d). Renderers use this alongside Placement::normal_to_world to pose mesh-local vectors.

Source

pub fn normal_to_world(&self, n: [f64; 3]) -> [f64; 3]

Maps a mesh-local unit normal to a world unit normal: normalize(R * (n / S)), the inverse-transpose for a rotation with a diagonal scale. Sides are preserved (the scale is positive), so culling and signs follow. Renderers use this to pose mesh-local normals.

Source

pub fn normal_to_local(&self, n: [f64; 3]) -> [f64; 3]

Maps a world unit normal’s direction to the mesh’s local frame: normalize(S * Rᵀ * n). The zero set of the local plane through inverse_apply of a world point with this normal is the preimage of the world plane’s zero set, with matching sides.

Trait Implementations§

Source§

impl Clone for Placement

Source§

fn clone(&self) -> Placement

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 Placement

Source§

impl Debug for Placement

Source§

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

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

impl Default for Placement

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Placement

Source§

fn eq(&self, other: &Placement) -> 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 Placement

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.