pub struct Quat {
pub w: f64,
pub v: Vec3,
}Expand description
A unit quaternion representing a 3D rotation.
Fields§
§w: f64Scalar part (w).
v: Vec3Vector part (x, y, z).
Implementations§
Source§impl Quat
impl Quat
Sourcepub fn new(w: f64, x: f64, y: f64, z: f64) -> Self
pub fn new(w: f64, x: f64, y: f64, z: f64) -> Self
Create a new quaternion from scalar and vector parts.
Sourcepub fn from_axis_angle(axis: &Vec3, angle: f64) -> Self
pub fn from_axis_angle(axis: &Vec3, angle: f64) -> Self
Create quaternion from axis-angle representation. axis should be a unit vector, angle in radians.
Sourcepub fn from_matrix(m: &Mat3) -> Quat
pub fn from_matrix(m: &Mat3) -> Quat
Convert rotation matrix to quaternion. Reference: Shepperd’s method (stable for all rotation matrices).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Quat
impl RefUnwindSafe for Quat
impl Send for Quat
impl Sync for Quat
impl Unpin for Quat
impl UnsafeUnpin for Quat
impl UnwindSafe for Quat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.