Struct cgmath::Euler

source ·
#[repr(C)]
pub struct Euler<A: Angle> { 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:

  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.

Implementations§

source§

impl<A: Angle> Euler<A>

source

pub 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§

source§

impl<A: Angle> ApproxEq for Euler<A>

§

type Epsilon = <A as ApproxEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> A::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn default_max_relative() -> A::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: A::Epsilon, max_relative: A::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn ulps_eq(&self, other: &Self, epsilon: A::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
source§

impl<A: Clone + Angle> Clone for Euler<A>

source§

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

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<A: Debug + Angle> Debug for Euler<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A> From<Euler<A>> for Basis3<A::Unitless>where A: Into<Rad<<A as Angle>::Unitless>> + Angle,

source§

fn from(src: Euler<A>) -> Basis3<A::Unitless>

Create a three-dimensional rotation matrix from a set of euler angles.

source§

impl<A> From<Euler<A>> for Matrix3<A::Unitless>where A: Angle + Into<Rad<<A as Angle>::Unitless>>,

source§

fn from(src: Euler<A>) -> Matrix3<A::Unitless>

Converts to this type from the input type.
source§

impl<A> From<Euler<A>> for Matrix4<A::Unitless>where A: Angle + Into<Rad<<A as Angle>::Unitless>>,

source§

fn from(src: Euler<A>) -> Matrix4<A::Unitless>

Converts to this type from the input type.
source§

impl<A> From<Euler<A>> for Quaternion<A::Unitless>where A: Angle + Into<Rad<<A as Angle>::Unitless>>,

source§

fn from(src: Euler<A>) -> Quaternion<A::Unitless>

Converts to this type from the input type.
source§

impl<S: BaseFloat> From<Quaternion<S>> for Euler<Rad<S>>

source§

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

Converts to this type from the input type.
source§

impl<A: PartialEq + Angle> PartialEq<Euler<A>> for Euler<A>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Angle + Rand> Rand for Euler<A>

source§

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

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

impl<A: Copy + Angle> Copy for Euler<A>

source§

impl<A: Eq + Angle> Eq for Euler<A>

source§

impl<A: Angle> StructuralEq for Euler<A>

source§

impl<A: Angle> 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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.