#[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: Angle> AbsDiffEq for Euler<A>
impl<A: Angle> AbsDiffEq for Euler<A>
Source§fn default_epsilon() -> A::Epsilon
fn default_epsilon() -> A::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: A::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: A::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: Angle> RelativeEq for Euler<A>
impl<A: Angle> RelativeEq for Euler<A>
Source§fn default_max_relative() -> A::Epsilon
fn default_max_relative() -> A::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: A::Epsilon,
max_relative: A::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: A::Epsilon, max_relative: A::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
.