Rot4

Struct Rot4 

Source
pub struct Rot4(pub Quat, pub Quat);
Expand description

A 4D rotation.

Tuple Fields§

§0: Quat§1: Quat

Implementations§

Source§

impl Rot4

Source

pub const IDENTITY: Self

Identity rotation.

Source

pub const NAN: Self

NAN rotation.

Source

pub const fn from_pq(p: Quat, q: Quat) -> Self

Constructs a new rotation from left and right isoclinic rotations represented by quaternions.

Source

pub fn from_slice(slice: &[f32]) -> Self

Source

pub fn write_to_slice(self, slice: &mut [f32])

Source

pub fn from_double_planar_rotation( a: Vec4, b: Vec4, c: Vec4, d: Vec4, angle_ab: f32, angle_cd: f32, ) -> Self

Constructs a rotation about two independent planes.

  • a b forms a plane and will be rotated by an angle angle_ab.
  • c d forms a plane and will be rotated by an angle angle_cd.
  • {a b c d} must be an orthonormal basis for R4.
Source

pub fn from_axes_angle(axis_1: Vec4, axis_2: Vec4, angle: f32) -> Option<Self>

Constructs a rotation about the plane specified by the two axes.

Returns None if the two axes don’t specify a plane (at least one axis is zero, or one is a multiple of the other).

Source

pub fn from_rotation_arc(from: Vec4, to: Vec4) -> Self

Constructs a minimal rotation which rotates from to to.

from and to need not be normalized,

Source

pub fn from_rotation_matrix(mat: Mat4) -> Self

Factors a rotation matrix into a Rot4.

If mat is not a rotation matrix, the output of this function is nonsense.

Source

pub fn inverse(self) -> Self

Computes the inverse rotation.

Source

pub fn normalize(self) -> Self

Normalizes the internal quaternions.

Source

pub fn is_finite(self) -> bool

Source

pub fn is_nan(self) -> bool

Source

pub fn is_normalized(self) -> bool

Source

pub fn is_near_identity(self) -> bool

Source

pub fn slerp(self, end: Self, s: f32) -> Self

Performs a smooth interpolation between two Rot4s.

Internally uses Quat::slerp.

Source

pub fn mul_vec4(self, rhs: Vec4) -> Vec4

Applies the rotation to a Vec4.

Source

pub fn mul_rot4(self, rhs: Self) -> Self

Composes this rotation with another.

let a: Rot4;
let b: Rot4;
let composition = a.mul_rot4(b);

let vector: Vec4;

let diff = composition.mul_vec4(vector) - b.mul_vec4(a.mul_vec4(vector));

assert!(diff.length_squared() < f32::EPSILON);
Source

pub fn mul_proj(self, rhs: Projection) -> Projection

Rotates a projection.

This internally just rotates all the axes.

It is preferred to rotate this way instead of just rotating the center of projection and then reconstructing the Projection because that may lead to jumps.

Source

pub fn from_rotation_xy(angle: f32) -> Self

Creates a rotation in the X-Y plane.

Source

pub fn from_rotation_xz(angle: f32) -> Self

Creates a rotation in the X-Z plane.

Source

pub fn from_rotation_xw(angle: f32) -> Self

Creates a rotation in the X-W plane.

Source

pub fn from_rotation_yz(angle: f32) -> Self

Creates a rotation in the Y-Z plane.

Source

pub fn from_rotation_yw(angle: f32) -> Self

Creates a rotation in the Y-W plane.

Source

pub fn from_rotation_zw(angle: f32) -> Self

Creates a rotation in the Z-W plane.

Trait Implementations§

Source§

impl Clone for Rot4

Source§

fn clone(&self) -> Rot4

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 Rot4

Source§

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

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

impl Default for Rot4

Source§

fn default() -> Rot4

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

impl Copy for Rot4

Auto Trait Implementations§

§

impl Freeze for Rot4

§

impl RefUnwindSafe for Rot4

§

impl Send for Rot4

§

impl Sync for Rot4

§

impl Unpin for Rot4

§

impl UnwindSafe for Rot4

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.