Struct fmath::types::Quaternion
source · [−]pub struct Quaternion { /* private fields */ }Expand description
Quaternion
Compact way to represent rotations without gimbal lock.
Implements: Clone, Copy, PartialEq, Debug
Implementations
sourceimpl Quaternion
impl Quaternion
sourcepub fn new(scalar: f32, x: f32, y: f32, z: f32) -> Self
pub fn new(scalar: f32, x: f32, y: f32, z: f32) -> Self
Create new Quaternion from given scalar and x y z values
sourcepub fn from_scalar_vector(scalar: f32, v: Vector3) -> Self
pub fn from_scalar_vector(scalar: f32, v: Vector3) -> Self
Create new Quaternion from given scalar and Vector3
sourcepub fn from_array(components: [f32; 4]) -> Self
pub fn from_array(components: [f32; 4]) -> Self
Create new Quaternion from f32;4
0 = scalar
1 2 3 = vector
sourcepub fn from_euler_angles(euler: Vector3) -> Self
pub fn from_euler_angles(euler: Vector3) -> Self
Create new Quaternion from given euler angles (Vector3)
Angles in Radians
sourcepub fn as_euler_angles(&self) -> Vector3
pub fn as_euler_angles(&self) -> Vector3
Get Quaternion rotation as euler angles
Angles in Radians
Note: if Quaternion was created from euler angles,
this euler angles representation might not have the same values as the original
sourcepub fn as_array(&self) -> &[f32; 4]
pub fn as_array(&self) -> &[f32; 4]
Get Quaternion values as f32 array
0 = scalar
1 2 3 = vector
sourcepub fn sqr_magnitude(&self) -> f32
pub fn sqr_magnitude(&self) -> f32
Returns: Quaternion length without applying square root
alias: norm
sourcepub fn norm(&self) -> f32
pub fn norm(&self) -> f32
Returns: Quaternion length without applying square root
alias: sqr_magnitude
Trait Implementations
sourceimpl Add<Quaternion> for Quaternion
impl Add<Quaternion> for Quaternion
type Output = Quaternion
type Output = Quaternion
The resulting type after applying the + operator.
sourceimpl Clone for Quaternion
impl Clone for Quaternion
sourcefn clone(&self) -> Quaternion
fn clone(&self) -> Quaternion
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Quaternion
impl Debug for Quaternion
sourceimpl Display for Quaternion
impl Display for Quaternion
sourceimpl Div<f32> for Quaternion
impl Div<f32> for Quaternion
sourceimpl Index<usize> for Quaternion
impl Index<usize> for Quaternion
sourceimpl IndexMut<usize> for Quaternion
impl IndexMut<usize> for Quaternion
sourceimpl Mul<Quaternion> for Quaternion
impl Mul<Quaternion> for Quaternion
type Output = Quaternion
type Output = Quaternion
The resulting type after applying the * operator.
sourceimpl Mul<Vector3> for Quaternion
impl Mul<Vector3> for Quaternion
sourceimpl Mul<f32> for Quaternion
impl Mul<f32> for Quaternion
sourceimpl PartialEq<Quaternion> for Quaternion
impl PartialEq<Quaternion> for Quaternion
sourcefn eq(&self, other: &Quaternion) -> bool
fn eq(&self, other: &Quaternion) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &Quaternion) -> bool
fn ne(&self, other: &Quaternion) -> bool
This method tests for !=.
sourceimpl Sub<Quaternion> for Quaternion
impl Sub<Quaternion> for Quaternion
type Output = Quaternion
type Output = Quaternion
The resulting type after applying the - operator.
impl Copy for Quaternion
impl StructuralPartialEq for Quaternion
Auto Trait Implementations
impl RefUnwindSafe for Quaternion
impl Send for Quaternion
impl Sync for Quaternion
impl Unpin for Quaternion
impl UnwindSafe for Quaternion
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more