#[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
sourceimpl<A> AbsDiffEq<Euler<A>> for Euler<A> where
A: Angle,
impl<A> AbsDiffEq<Euler<A>> for Euler<A> where
A: Angle,
sourcefn default_epsilon() -> <A as AbsDiffEq<A>>::Epsilon
fn default_epsilon() -> <A as AbsDiffEq<A>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq<A>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq<A>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of AbsDiffEq::abs_diff_eq
.
sourceimpl<A> From<Euler<A>> for Basis3<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
impl<A> From<Euler<A>> for Basis3<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
sourceimpl<A> From<Euler<A>> for Matrix3<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
impl<A> From<Euler<A>> for Matrix3<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
sourceimpl<A> From<Euler<A>> for Matrix4<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
impl<A> From<Euler<A>> for Matrix4<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
sourceimpl<A> From<Euler<A>> for Quaternion<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
impl<A> From<Euler<A>> for Quaternion<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
sourceimpl<S> From<Quaternion<S>> for Euler<Rad<S>> where
S: BaseFloat,
impl<S> From<Quaternion<S>> for Euler<Rad<S>> where
S: BaseFloat,
sourcefn from(src: Quaternion<S>) -> Euler<Rad<S>>
fn from(src: Quaternion<S>) -> Euler<Rad<S>>
Converts to this type from the input type.
sourceimpl<A> RelativeEq<Euler<A>> for Euler<A> where
A: Angle,
impl<A> RelativeEq<Euler<A>> for Euler<A> where
A: Angle,
sourcefn default_max_relative() -> <A as AbsDiffEq<A>>::Epsilon
fn default_max_relative() -> <A as AbsDiffEq<A>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq<A>>::Epsilon,
max_relative: <A as AbsDiffEq<A>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Euler<A>,
epsilon: <A as AbsDiffEq<A>>::Epsilon,
max_relative: <A as AbsDiffEq<A>>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
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
The inverse of RelativeEq::relative_eq
.
sourceimpl<A> UlpsEq<Euler<A>> for Euler<A> where
A: Angle,
impl<A> UlpsEq<Euler<A>> for Euler<A> where
A: Angle,
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
impl<A> Copy for Euler<A> where
A: Copy,
impl<A> Eq for Euler<A> where
A: Eq,
impl<A> StructuralEq for Euler<A>
impl<A> StructuralPartialEq for Euler<A>
Auto Trait Implementations
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
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
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
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 more
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).
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.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.