Struct cgmath::Euler [] [src]

pub struct Euler<A: Angle> {
    pub x: A,
    pub y: A,
    pub z: A,
}

A set of Euler angles representing a rotation in three-dimensional space.

This type is marked as #[repr(C, packed)].

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 or 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:

  1. a 90° rotation around the x axis
  2. a 45° rotation around the y axis
  3. 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.

Methods

impl<A: Angle> Euler<A>
[src]

fn new(x: A, y: A, z: A) -> Euler<A>

Construct a set of euler angles.

Arguments

  • x - The angle to apply around the x axis. Also known at the pitch.
  • y - The angle to apply around the y axis. Also known at the yaw.
  • z - The angle to apply around the z axis. Also known at the roll.

Trait Implementations

impl<A: Debug + Angle> Debug for Euler<A>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<A: Clone + Angle> Clone for Euler<A>
[src]

fn clone(&self) -> Euler<A>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<A: Copy + Angle> Copy for Euler<A>
[src]

impl<A: Eq + Angle> Eq for Euler<A>
[src]

impl<A: PartialEq + Angle> PartialEq for Euler<A>
[src]

fn eq(&self, __arg_0: &Euler<A>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Euler<A>) -> bool

This method tests for !=.

impl<A: Decodable + Angle> Decodable for Euler<A>
[src]

fn decode<__DA: Decoder>(__arg_0: &mut __DA) -> Result<Euler<A>, __DA::Error>

impl<A: Encodable + Angle> Encodable for Euler<A>
[src]

fn encode<__SA: Encoder>(&self, __arg_0: &mut __SA) -> Result<(), __SA::Error>

impl<S: BaseFloat> From<Quaternion<S>> for Euler<Rad<S>>
[src]

fn from(src: Quaternion<S>) -> Euler<Rad<S>>

Performs the conversion.

impl<A: Angle> ApproxEq for Euler<A>
[src]

type Epsilon = A::Unitless

fn approx_eq_eps(&self, other: &Euler<A>, epsilon: &A::Unitless) -> bool

fn approx_epsilon() -> Self::Epsilon

fn approx_eq(&self, other: &Self) -> bool

impl<A: Angle + Rand> Rand for Euler<A>
[src]

fn rand<R: Rng>(rng: &mut R) -> Euler<A>

Generates a random instance of this type using the specified source of randomness. Read more