Skip to main content

Linear

Struct Linear 

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

A linear map of an entity’s local space (a transform’s 3x3 part), computed in f64 from the f32 entries and rounded once per value: what crate::Component::apply_linear maps local-space geometry by.

Points go through M; normals through M^-T with the determinant’s sign kept (they stay on the side they were on) and directions through M, both then of unit length (zero stays zero); a tangent’s w (the bitangent sign) and a triangle’s winding flip when the determinant is negative (Linear::mirrors). A singular map (Linear::singular) turns no normal or tangent.

Implementations§

Source§

impl Linear

Source

pub fn of(t: &Transform) -> Linear

The 3x3 part of t.

Source

pub fn new(cols: [[f32; 3]; 3]) -> Linear

The map with these columns (images of local +X, +Y, +Z).

Source

pub fn of_f64(c: [[f64; 3]; 3]) -> Linear

The map with these columns held in f64: a part composed in f64 (a chain of bone transforms) taken as it is, not rounded to f32 first.

Source

pub fn mirror_x() -> Linear

x negated: the mirror a mirroring placement keeps out of its transform, M = M' * MIRROR_X.

Source

pub fn determinant(&self) -> f64

Source

pub fn singular(&self) -> bool

Whether the map has no inverse to turn normals and tangents by: its basis is degenerate, as Transform::classify says of a transform with this linear part (or its determinant is not finite). The one rule Linear::normal, Linear::tangent and Linear::inverse_columns answer None by.

Source

pub fn inverse_columns(&self) -> Option<[[f64; 3]; 3]>

The columns of M^-1 (the transpose of the cofactors over the determinant); None for a singular map (Linear::singular).

Source

pub fn mirrors(&self) -> bool

Whether it reverses orientation (negative determinant): triangles must be reversed and tangent w negated.

Source

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

The uniform scale s when the map is a rotation or mirror times s (columns orthogonal and of one length, to a relative 1e-6): a sphere stays a sphere of s times its radius. None for any other map.

Source

pub fn axis_map(&self) -> Option<[usize; 3]>

For each local axis, the world axis it maps onto, when every column has exactly one nonzero entry (a signed, scaled permutation): an axis-aligned box stays one. None for any other map.

Source

pub fn point(&self, p: [f32; 3]) -> [f32; 3]

M p.

Source

pub fn normal(&self, n: [f32; 3]) -> Option<[f32; 3]>

M^-T n times the determinant’s sign, of unit length (zero stays zero); None under a singular map (Linear::singular), which turns no normal.

Source

pub fn tangent(&self, t: [f32; 4]) -> Option<[f32; 4]>

M t of unit length (zero stays zero), w negated under a mirror; None under a singular map (Linear::singular).

Trait Implementations§

Source§

impl Clone for Linear

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 Linear

Source§

impl Debug for Linear

Source§

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

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

impl PartialEq for Linear

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 Linear

Source§

impl VertexMap for Linear

Source§

fn point(&self, p: [f32; 3]) -> [f32; 3]

A point (a position, a Semantic::Point).
Source§

fn normal(&self, n: [f32; 3]) -> Option<[f32; 3]>

A surface normal. None where the map turns no normal (a singular map).
Source§

fn tangent(&self, t: [f32; 4]) -> Option<[f32; 4]>

A tangent: xyz and the bitangent sign w. None where the map turns no tangent.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.