Projection

Struct Projection 

Source
pub struct Projection {
    pub p: Vec4,
    pub local_x: Vec4,
    pub local_y: Vec4,
    pub local_z: Vec4,
    pub matrix_inverse: Mat4,
}
Expand description

A 4D -> 3D stereographic projection from S3 -> R3.

Fields§

§p: Vec4

Center of projection

§local_x: Vec4

Three elements of the orthonormal basis for the tangent plane of a point – plane is centered at 0 rather than p.

§local_y: Vec4§local_z: Vec4§matrix_inverse: Mat4

Inverse matrix, used when projecting to strip a dimension out.

Implementations§

Source§

impl Projection

Source

pub const UNIT_PROJECTION: Projection

The unit projection uses Vec4::W as the center of projection.

Source

pub fn new(p: Vec4) -> Self

Creates a new projection with p as the center.

Picks an arbitrary orthonormal basis for local_x, local_y, and local_z.

Source

pub fn from_orthonormal_basis(p: Vec4, q: Vec4, r: Vec4, s: Vec4) -> Self

Constructs a projection from an existing orthonormal basis.

Source

pub fn project(self, point: Vec4) -> Vec3

Projects a point according to the stereographic projection described by self.

Source

pub fn project_normal(self, at: Vec4, normal: Vec4) -> Vec3

Projects a tangent vector to a point in an angle-preserving way.

If:

  • normal is tangent to the hypersphere at at, ie normal.dot(at) == 0
  • at is part of some shape K which lives on the surface of the hypersphere
  • K' is the projection of K
  • at' is the projection of at
  • x(t) = (at + t * normal).normalize() is a spherical line segment for t > 0
  • x(t) intersects K at an angle alpha
  • n' is self.project_normal(at, normal)

Then:

  • y(t) = at' + t * n' intersects K' at an angle alpha.

This is meaningful because it means that normal vectors remain normal vectors.

Trait Implementations§

Source§

impl Clone for Projection

Source§

fn clone(&self) -> Projection

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Projection

Source§

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

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

impl Copy for Projection

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.