Trait Angle

Source
pub trait Angle:
    Clone
    + FromAngle<Self>
    + PartialEq
    + PartialOrd
    + Zero {
    type Scalar: Float;

Show 19 methods // Required methods fn new(value: Self::Scalar) -> Self; fn period() -> Self::Scalar; fn scalar(&self) -> Self::Scalar; fn set_scalar(&mut self, value: Self::Scalar); fn normalize(self) -> Self; fn is_normalized(&self) -> bool; fn sin(self) -> Self::Scalar; fn cos(self) -> Self::Scalar; fn tan(self) -> Self::Scalar; fn sin_cos(self) -> (Self::Scalar, Self::Scalar); fn asin(value: Self::Scalar) -> Self; fn acos(value: Self::Scalar) -> Self; fn atan(value: Self::Scalar) -> Self; fn atan2(x: Self::Scalar, y: Self::Scalar) -> Self; fn full_turn() -> Self; fn half_turn() -> Self; fn quarter_turn() -> Self; fn invert(self) -> Self; fn reflect_x(self) -> Self;
}
Expand description

Base functionality for all angle types.

Required Associated Types§

Source

type Scalar: Float

Internal type storing the angle value.

Required Methods§

Source

fn new(value: Self::Scalar) -> Self

Construct a new angle.

Equivalent to constructing the tuple struct directly, eg. Deg(value), but usable in a generic context.

Source

fn period() -> Self::Scalar

The length of a full rotation.

Source

fn scalar(&self) -> Self::Scalar

Return the scalar (unitless) value.

Equivalent to self.0 or to doing let Deg(val) = self

Source

fn set_scalar(&mut self, value: Self::Scalar)

Set the internal scalar value of the angle.

Source

fn normalize(self) -> Self

Normalize the angle, wrapping it back into the standard domain.

After normalization, an angle will be in the range [0, self.period()).

For performance reasons, normalization does not happen automatically during most operations. Thus, when passing an angle to a method that expects it to be within the standard domain, first normalize the angle.

Source

fn is_normalized(&self) -> bool

Whether the angle is in the standard domain.

Source

fn sin(self) -> Self::Scalar

Compute the sine of an angle.

Source

fn cos(self) -> Self::Scalar

Compute the cosine of an angle.

Source

fn tan(self) -> Self::Scalar

Compute the tangent of an angle.

Source

fn sin_cos(self) -> (Self::Scalar, Self::Scalar)

Simultaneously compute sine and cosine.

Source

fn asin(value: Self::Scalar) -> Self

Compute the arcsine of a value, returning an angle.

Source

fn acos(value: Self::Scalar) -> Self

Compute the arccosine of a value, returning an angle.

Source

fn atan(value: Self::Scalar) -> Self

Compute the arctangent of a value, returning an angle.

Source

fn atan2(x: Self::Scalar, y: Self::Scalar) -> Self

Compute the arctangent of a value, using information from the numerator and denominator in order to increase the domain.

Source

fn full_turn() -> Self

Return one full rotation in some unit.

Equivalent to Self(Self::period()).

Source

fn half_turn() -> Self

Return one half of a full rotation in some unit.

Source

fn quarter_turn() -> Self

Return one quarter of a full rotation in some unit.

Source

fn invert(self) -> Self

Return the inverse of an angle.

The inverse is equivalent to adding half a rotation or inverting the unit vector pointing from the origin along the angle.

Source

fn reflect_x(self) -> Self

Return the reflection of an angle over the x axis.

Equivalent to full_turn() - self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Float> Angle for ArcMinutes<T>

Source§

impl<T: Float> Angle for ArcSeconds<T>

Source§

impl<T: Float> Angle for Deg<T>

Source§

impl<T: Float> Angle for Gon<T>

Source§

impl<T: Float> Angle for Rad<T>

Source§

impl<T: Float> Angle for Turns<T>