Skip to main content

SourceFrame

Struct SourceFrame 

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

A source coordinate frame described in world terms: world[i] = sign_i * source[axes[i]] * metres_per_unit for positions, without the scale for directions.

Implementations§

Source§

impl SourceFrame

Source

pub const WORLD: SourceFrame

The world frame itself.

Source

pub const ENU: SourceFrame

East, north, up, metres (right-handed, z up): a source’s own frame, one writer’s internal frame, and Blender’s. world = (east, up, -north); back out, (east, north, up) = (x, -z, y).

Source

pub const fn new(axes: [Axis; 3], metres_per_unit: f64) -> SourceFrame

A frame from constant parts. Panics (a compile error in a const) when the axes are not a permutation or the scale is not finite and positive: frames written in code are checked where they are written. For frames read from data use SourceFrame::try_new.

Source

pub const fn try_new( axes: [Axis; 3], metres_per_unit: f64, ) -> Result<SourceFrame, FrameError>

Source

pub const fn axes(&self) -> [Axis; 3]

For world axis i, the source axis (with sign) it is taken from.

Source

pub const fn metres_per_unit(&self) -> f64

Source

pub const fn determinant(&self) -> i32

The determinant of the axis part: +1 when the source is right-handed like the world, -1 when it is left-handed (converting mirrors).

Source

pub const fn flips_winding(&self) -> bool

Whether converting a mesh mirrors it, so its triangles’ winding must be reversed to keep their fronts.

Source

pub const fn inverse(&self) -> SourceFrame

The world frame described in this frame’s terms: converting with the inverse undoes a conversion.

Source

pub fn direction(&self, d: [f32; 3]) -> [f32; 3]

A direction (normal, tangent, axis): signed permutation only, bit-exact.

Source

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

A position: signed permutation, then the unit scale (f64, rounded once; exact for scale 1).

Source

pub fn transform(&self, m: &Transform) -> Transform

A transform world = M * local whose local and world sides are both in this frame: C M C^-1. The linear part only moves and negates entries (bit-exact; the scale cancels), the translation converts as a point.

Source

pub fn direction_to_source(&self, d: [f32; 3]) -> [f32; 3]

World to this frame: the inverse conversions.

Source

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

Source

pub fn transform_to_source(&self, m: &Transform) -> Transform

Source

pub fn length_to_source(&self, l: f32) -> f32

A length in metres, in this frame’s units (exact for scale 1).

Source

pub fn inverse_length_to_source(&self, l: f32) -> f32

One over a length in metres, in this frame’s units (exact for scale 1).

Source

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

A tangent (xyz, w the bitangent sign) in this frame: xyz as a direction, w negated where the frame mirrors.

Source

pub fn plane_to_source(&self, plane: [f32; 4]) -> [f32; 4]

A plane (n, d) (dot(n, p) + d = 0 for its world points p) in this frame: the normal as a direction, the offset as a length.

Source

pub fn from_world_matrix_to_source(&self, m: [[f32; 4]; 4]) -> [[f32; 4]; 4]

A 4 x 4 matrix (by columns) that takes world positions to another space (the view, the clip), made to take this frame’s positions to the same space: M C, C this frame’s map to the world, so (M C) (C^-1 p) = M p and what it gives is unchanged. Column j of M C is the column of M for the world axis this frame’s axis j is, signed and times the unit scale: for scale 1 the entries only move and change sign (bit-exact), and the product with a converted point sums the same terms in this frame’s axis order (the same order, so the same bits, for a frame that only changes signs).

Source

pub fn to_world_matrix_to_source(&self, m: [[f32; 4]; 4]) -> [[f32; 4]; 4]

A 4 x 4 matrix (by columns) that gives world positions (from the view, the clip), made to give this frame’s: C^-1 M, each column’s xyz converted as a point and its w kept.

Source

pub fn world_matrix_to_source(&self, m: [[f32; 4]; 4]) -> [[f32; 4]; 4]

A 4 x 4 matrix (by columns) from one world-frame space to another (an object’s to the world, a joint’s) in this frame’s terms: C^-1 M C, as SourceFrame::transform_to_source converts an affine transform.

Trait Implementations§

Source§

impl Clone for SourceFrame

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 SourceFrame

Source§

impl Debug for SourceFrame

Source§

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

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

impl PartialEq for SourceFrame

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 SourceFrame

Source§

impl VertexMap for SourceFrame

A frame conversion moves a mesh’s streams as it moves positions and directions: normals and tangents by the signed permutation (a uniform scale turns no direction), a tangent’s bitangent sign negated where the conversion mirrors.

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.