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
impl Placement
Sourcepub fn validate(&self) -> Result<()>
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.
Sourcepub fn uniform_scale(&self) -> Option<f64>
pub fn uniform_scale(&self) -> Option<f64>
The uniform scale when every component is equal, None otherwise.
Sourcepub fn apply(&self, p: [f64; 3]) -> [f64; 3]
pub fn apply(&self, p: [f64; 3]) -> [f64; 3]
Maps a point of the mesh to the world: rotation * (scale * p) + translation.
Sourcepub fn inverse_apply(&self, q: [f64; 3]) -> [f64; 3]
pub fn inverse_apply(&self, q: [f64; 3]) -> [f64; 3]
Maps a world point back to the mesh: (scale⁻¹ * rotationᵀ) * (q - translation).
Sourcepub fn apply_direction(&self, d: [f64; 3]) -> [f64; 3]
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.
Sourcepub fn normal_to_world(&self, n: [f64; 3]) -> [f64; 3]
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.
Sourcepub fn normal_to_local(&self, n: [f64; 3]) -> [f64; 3]
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.