Skip to main content

LookAngles

Struct LookAngles 

Source
pub struct LookAngles {
    pub yaw: f32,
    pub pitch: f32,
}
Expand description

A look direction as yaw and pitch, Z-up.

  • yaw turns around world Z. Yaw 0 looks along +Y and increasing yaw turns toward +X (clockwise seen from above).
  • pitch is the angle above the horizontal plane: positive looks up.

There is no roll. orientation gives the matching Camera::orientation, and from_orientation reads one back, dropping any roll it carried. The first- and third-person controllers store their look this way.

Fields§

§yaw: f32

Rotation around world Z, in radians.

§pitch: f32

Angle above the horizontal plane, in radians.

Implementations§

Source§

impl LookAngles

Source

pub const FORWARD: LookAngles

Looking along +Y, level.

Source

pub const fn new(yaw: f32, pitch: f32) -> LookAngles

Build from yaw and pitch in radians.

Source

pub fn from_orientation(orientation: Quat) -> LookAngles

Read the look out of a camera orientation. Roll is dropped.

Looking straight up or down leaves yaw undefined; the result then takes whatever yaw the rounding gives.

Source

pub fn from_direction(direction: Vec3) -> LookAngles

Read the look out of a direction. A zero direction gives FORWARD.

Source

pub fn orientation(self) -> Quat

The camera orientation for this look.

Source

pub fn direction(self) -> Vec3

The full look direction, pitch included. Unit length.

Source

pub fn forward(self) -> Vec3

The look direction flattened onto the ground plane, for movement. Unit length.

Source

pub fn right(self) -> Vec3

The ground-plane right of forward, for strafing. Unit length.

Source

pub fn turned(self, yaw: f32, pitch: f32) -> LookAngles

Turned by yaw and pitch radians. Pitch is not clamped; follow with with_pitch_clamped.

Source

pub fn with_pitch_clamped(self, min: f32, max: f32) -> LookAngles

With pitch held to min..=max.

Trait Implementations§

Source§

impl Clone for LookAngles

Source§

fn clone(&self) -> LookAngles

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for LookAngles

Source§

impl Debug for LookAngles

Source§

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

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

impl Default for LookAngles

Source§

fn default() -> LookAngles

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for LookAngles

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<LookAngles, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LookAngles

Source§

fn eq(&self, other: &LookAngles) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for LookAngles

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LookAngles

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.