pub struct Quaternion {
pub w: f32,
pub x: f32,
pub y: f32,
pub z: f32,
}Expand description
The four components of a rotation quaternion, Hamilton convention, by name.
Named rather than an array because the order of four numbers is the one convention no
type can check: PX4’s q[4] and ArduPilot’s Quaternion put the scalar first, while
ROS, Eigen, glam’s to_array and nalgebra’s coords and From<[f32; 4]> put it last.
A quaternion read in the other order is still a finite unit quaternion, and rotates the
wrong way. So there is no conversion from an array and no positional constructor: a
caller writes Quaternion { w: q.w, x: q.i, y: q.j, z: q.k } from nalgebra, or
{ w: q[0], x: q[1], .. } from PX4, and the order is on the page.
It carries no frames; Attitude’s constructors say which rotation it is.
Fields§
§w: f32The scalar part, cos(θ/2).
x: f32The first vector component, sin(θ/2) times the axis’s first.
y: f32The second vector component.
z: f32The third vector component.
Implementations§
Source§impl Quaternion
impl Quaternion
Trait Implementations§
Source§impl Clone for Quaternion
impl Clone for Quaternion
impl Copy for Quaternion
Source§impl Debug for Quaternion
impl Debug for Quaternion
Source§impl Format for Quaternion
Available on crate feature defmt only.
impl Format for Quaternion
defmt only.Source§impl PartialEq for Quaternion
impl PartialEq for Quaternion
impl StructuralPartialEq for Quaternion
Auto Trait Implementations§
impl Freeze for Quaternion
impl RefUnwindSafe for Quaternion
impl Send for Quaternion
impl Sync for Quaternion
impl Unpin for Quaternion
impl UnsafeUnpin for Quaternion
impl UnwindSafe for Quaternion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.