Struct Angle

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

Angular position.

Implementations§

Source§

impl Angle

Source

pub const ZERO: Self

Angle representing zero rotation.

Source

pub const QUARTER_TURN: Self

Angle representing a quarter turn around a full circle.

Source

pub const HALF_TURN: Self

Angle representing a half turn around a full circle.

Source

pub const FULL_TURN: Self

Angle representing a full turn around a circle.

Source

pub const MIN: Self

Smallest value that can be represented by the Angle type.

Equivalent to f64::MIN radians.

Source

pub const MAX: Self

Largest value that can be represented by the Angle type.

Equivalent to f64::MAX radians.

Source

pub const EPSILON: Self

Machine epsilon value for Angle.

Source

pub const fn from_radians(radians: f64) -> Self

Creates a new Angle from a value in radians.

Source

pub const fn from_gradians(gradians: f64) -> Self

Creates a new Angle from a value in gradians.

Source

pub const fn from_degrees(degrees: f64) -> Self

Creates a new Angle from a value in degrees.

Source

pub const fn from_turns(turns: f64) -> Self

Creates a new Angle from a value in turns (revolutions).

Source

pub fn asin(y: f64) -> Self

Computes the arcsine of a number. Return value is in the range [-pi/2, pi/2] or NaN if the angle is outside the range [-1, 1].

Source

pub fn acos(x: f64) -> Self

Computes the arccosine of a number. Return value is in the range [0, pi] or NaN if the number is outside the range [-1, 1].

Source

pub fn atan(tan: f64) -> Self

Computes the arctangent of an angle. Return value is in radians in the range [-pi/2, pi/2];

Source

pub fn atan2(y: f64, x: f64) -> Self

Computes the four quadrant arctangent angle of y and x.

Source

pub const fn as_degrees(&self) -> f64

Returns this angle’s value in degrees.

Source

pub fn as_turns(&self) -> f64

Returns this angle’s value in turns (revolution).

Source

pub const fn as_radians(&self) -> f64

Returns this angle’s value in radians.

Source

pub const fn as_gradians(&self) -> f64

Returns this angle’s value in gradians.

Source

pub fn wrapped(&self) -> Self

Normalizes an angle to the bounds [-pi, pi].

Source

pub fn wrapped_positive(&self) -> Self

Normalizes an angle to the bounds [0, 2pi].

Source

pub const fn abs(self) -> Self

Computes the absolute value of self.

Source

pub const fn signum(self) -> f64

Returns a number that represents the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NaN if the number is NaN
Source

pub const fn copysign(self, sign: Self) -> Self

Returns an angle composed of the magnitude of self and the sign of sign.

Equal to self if the sign of self and sign are the same, otherwise equal to -self. If self is a NaN, then a NaN with the same payload as self and the sign bit of sign is returned.

If sign is a NaN, then this operation will still carry over its sign into the result. Note that IEEE 754 doesn’t assign any meaning to the sign bit in case of a NaN, and as Rust doesn’t guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the result of copysign with sign being a NaN might produce an unexpected or non-portable result. See the specification of NaN bit patterns for more info.

Source

pub fn mul_add(self, a: Self, b: Self) -> Self

Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.

Using mul_add may be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.

Source

pub fn div_euclid(self, rhs: Self) -> Self

Calculates Euclidean division.

Source

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

The positive difference of two numbers.

  • If self <= other: 0.0
  • Else: self - other
Source

pub fn sin(self) -> f64

Computes the sine of an angle.

Source

pub fn cos(self) -> f64

Computes the cosine of an angle.

Source

pub fn tan(self) -> f64

Computes the tangent of an angle.

Source

pub fn sin_cos(self) -> (f64, f64)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

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

Performs the + operation. Read more
Source§

impl AddAssign for Angle

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Angle

Source§

fn clone(&self) -> Angle

Returns a duplicate 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 Div<f64> for Angle

Source§

type Output = Angle

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f64> for Angle

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl From<Position> for Angle

Source§

fn from(value: Position) -> Self

Converts to this type from the input type.
Source§

impl Mul<f64> for Angle

Source§

type Output = Angle

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f64> for Angle

Source§

fn mul_assign(&mut self, rhs: f64)

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

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

Source§

type Output = Angle

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Angle

Source§

fn sub_assign(&mut self, rhs: 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, 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> 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 = 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.