retrofire_core::math::angle

Struct Angle

Source
pub struct Angle(/* private fields */);
Expand description

A scalar angular quantity.

Prevents confusion between degrees and radians by requiring the use of one of the named constructors to create an Angle, as well as one of the named getter methods to obtain the angle as a raw f32 value.

Implementations§

Source§

impl Angle

Source

pub const ZERO: Self = _

A zero degree angle.

Source

pub const RIGHT: Self = _

A 90 degree angle.

Source

pub const STRAIGHT: Self = _

A 180 degree angle.

Source

pub const FULL: Self = _

A 360 degree angle.

Source

pub const fn to_rads(self) -> f32

Returns the value of self in radians.

§Examples
assert_eq!(degs(90.0).to_rads(), f32::consts::FRAC_PI_2);
Source

pub fn to_degs(self) -> f32

Returns the value of self in degrees.

§Examples
assert_eq!(turns(2.0).to_degs(), 720.0);
Source

pub fn to_turns(self) -> f32

Returns the value of self in turns.

§Examples
assert_eq!(degs(180.0).to_turns(), 0.5);
Source

pub fn min(self, other: Self) -> Self

Returns the minimum of self and other.

Source

pub fn max(self, other: Self) -> Self

Returns the maximum of self and other.

Source

pub fn clamp(self, min: Self, max: Self) -> Self

Returns self clamped to the range min..=max.

§Examples
let (min, max) = (degs(0.0), degs(45.0));

assert_eq!(degs(100.0).clamp(min, max), max);

assert_eq!(degs(30.0).clamp(min, max), degs(30.0));

assert_eq!(degs(-10.0).clamp(min, max), min);

Trait Implementations§

Source§

impl Add for Angle

Source§

type Output = Angle

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl Affine for Angle

Source§

const DIM: usize = 1usize

The dimension of Self.
Source§

type Space = ()

The space that Self is the element type of.
Source§

type Diff = Angle

The (signed) difference of two values of Self. Diff must have the same dimension as Self.
Source§

fn add(&self, other: &Self) -> Self

Adds diff to self component-wise. Read more
Source§

fn sub(&self, other: &Self) -> Self

Subtracts other from self, returning the (signed) difference. Read more
Source§

impl ApproxEq for Angle

Source§

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

Returns whether self and other are approximately equal, using the relative epsilon rel_eps.
Source§

fn relative_epsilon() -> Self

Returns the default relative epsilon of type E.
Source§

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

Returns whether self and other are approximately equal. Uses the epsilon returned by Self::relative_epsilon.
Source§

impl Clone for Angle

Source§

fn clone(&self) -> Angle

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 Debug for Angle

Source§

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

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

impl Default for Angle

Source§

fn default() -> Angle

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

impl Display for Angle

Source§

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

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

impl Div<f32> for Angle

Source§

type Output = Angle

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self

Performs the / operation. Read more
Source§

impl Linear for Angle

Source§

type Scalar = f32

The scalar type associated with Self.
Source§

fn zero() -> Self

Returns the additive identity of Self.
Source§

fn neg(&self) -> Self

Returns the additive inverse of self.
Source§

fn mul(&self, scalar: f32) -> Self

Multiplies all components of self by scalar. Read more
Source§

impl Mul<f32> for Angle

Source§

type Output = Angle

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self

Performs the * operation. Read more
Source§

impl Neg for Angle

Source§

type Output = Angle

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Angle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Rem for Angle

Source§

type Output = Angle

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self

Performs the % operation. Read more
Source§

impl Sub for Angle

Source§

type Output = Angle

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl Copy for Angle

Source§

impl StructuralPartialEq for Angle

Auto Trait Implementations§

§

impl Freeze for Angle

§

impl RefUnwindSafe for Angle

§

impl Send for Angle

§

impl Sync for Angle

§

impl Unpin for Angle

§

impl UnwindSafe for Angle

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 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.
Source§

impl<V> Vary for V
where V: Clone + Linear<Scalar = f32>,

Source§

fn step(&self, delta: &<V as Vary>::Diff) -> V

Adds delta to self.

Source§

type Iter = Iter<V>

The iterator returned by the vary method.
Source§

type Diff = <V as Affine>::Diff

The difference type of Self.
Source§

fn vary(self, step: <V as Vary>::Diff, n: Option<u32>) -> <V as Vary>::Iter

Returns an iterator that yields values such that the first value equals self, and each subsequent value is offset by step from its predecessor using the step method. If max is Some(n), stops after n steps, otherwise infinite. Read more
Source§

fn dv_dt(&self, other: &V, recip_dt: f32) -> <V as Vary>::Diff

Returns, conceptually, (other - self) / dt.
Source§

fn z_div(&self, z: f32) -> V

Performs perspective division.
Source§

fn vary_to(self, other: Self, n: u32) -> Self::Iter

Linearly distributes values between self and other inclusive.
Source§

fn lerp(&self, other: &Self, t: f32) -> Self

Linearly interpolates between self and other. Read more