#[repr(C)]pub struct Euler<A> {
pub x: A,
pub y: A,
pub z: A,
}
Expand description
A set of Euler angles representing a rotation in three-dimensional space.
This type is marked as #[repr(C)]
.
The axis rotation sequence is XYZ. That is, the rotation is first around the X axis, then the Y axis, and lastly the Z axis (using intrinsic rotations). Since all three rotation axes are used, the angles are Tait–Bryan angles rather than proper Euler angles.
§Ranges
- x: [-pi, pi]
- y: [-pi/2, pi/2]
- z: [-pi, pi]
§Defining rotations using Euler angles
Note that while Euler angles are intuitive to define, they are prone to
gimbal lock and are challenging to interpolate between. Instead we
recommend that you convert them to a more robust representation, such as a
quaternion or a rotation matrix. To this end, From<Euler<A>>
conversions
are provided for the following types:
For example, to define a quaternion that applies the following:
- a 90° rotation around the x axis
- a 45° rotation around the y axis
- a 15° rotation around the z axis
you can use the following code:
use cgmath::{Deg, Euler, Quaternion};
let rotation = Quaternion::from(Euler {
x: Deg(90.0),
y: Deg(45.0),
z: Deg(15.0),
});
Fields§
§x: A
The angle to apply around the x axis. Also known at the pitch.
y: A
The angle to apply around the y axis. Also known at the yaw.
z: A
The angle to apply around the z axis. Also known at the roll.
Implementations§
Trait Implementations§
Source§impl<A> AbsDiffEq for Euler<A>where
A: Angle,
impl<A> AbsDiffEq for Euler<A>where
A: Angle,
Source§fn default_epsilon() -> <A as AbsDiffEq>::Epsilon
fn default_epsilon() -> <A as AbsDiffEq>::Epsilon
Source§fn abs_diff_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Euler<A>, epsilon: <A as AbsDiffEq>::Epsilon, ) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.Source§impl<A> RelativeEq for Euler<A>where
A: Angle,
impl<A> RelativeEq for Euler<A>where
A: Angle,
Source§fn default_max_relative() -> <A as AbsDiffEq>::Epsilon
fn default_max_relative() -> <A as AbsDiffEq>::Epsilon
Source§fn relative_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq>::Epsilon,
max_relative: <A as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Euler<A>, epsilon: <A as AbsDiffEq>::Epsilon, max_relative: <A as AbsDiffEq>::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.Source§impl<A> UlpsEq for Euler<A>where
A: Angle,
impl<A> UlpsEq for Euler<A>where
A: Angle,
Source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
impl<A> Copy for Euler<A>where
A: Copy,
impl<A> Eq for Euler<A>where
A: Eq,
impl<A> StructuralPartialEq for Euler<A>
Auto Trait Implementations§
impl<A> Freeze for Euler<A>where
A: Freeze,
impl<A> RefUnwindSafe for Euler<A>where
A: RefUnwindSafe,
impl<A> Send for Euler<A>where
A: Send,
impl<A> Sync for Euler<A>where
A: Sync,
impl<A> Unpin for Euler<A>where
A: Unpin,
impl<A> UnwindSafe for Euler<A>where
A: UnwindSafe,
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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.