Direction

Trait Direction 

Source
pub trait Direction<T>: Sized {
    // Required methods
    fn to_degrees(self) -> Degrees<T>;
    fn to_radians(self) -> Radians<T>;
    fn to_rotations(self) -> Rotations<T>;
    fn to_cardinal(self, bias: Cardinal) -> Cardinal;
    fn to_octal(self) -> Octal;
    fn from_vec2(v: Vec2<T>) -> Self;
    fn sin_cos(self) -> (T, T);

    // Provided method
    fn norm(self) -> Vec2<T> { ... }
}
Expand description

A type that represents a direction in 2D space.

Required Methods§

Source

fn to_degrees(self) -> Degrees<T>

Angle of the direction in degrees.

Source

fn to_radians(self) -> Radians<T>

Angle of the direction in radians.

Source

fn to_rotations(self) -> Rotations<T>

Angle of the direction in rotations.

Source

fn to_cardinal(self, bias: Cardinal) -> Cardinal

Get an approximately equivalent Cardinal direction.

Source

fn to_octal(self) -> Octal

Get an approximately equivalent Octal direction.

Source

fn from_vec2(v: Vec2<T>) -> Self

The direction from the direction of a vector.

Source

fn sin_cos(self) -> (T, T)

The (sin, cos) pair for this direction.

Provided Methods§

Source

fn norm(self) -> Vec2<T>

Normal representation of this direction.

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> Direction<T> for Cardinal

Source§

impl<T: Float> Direction<T> for Octal

Source§

impl<T: Float> Direction<T> for Degrees<T>

Source§

impl<T: Float> Direction<T> for Radians<T>

Source§

impl<T: Float> Direction<T> for Rotations<T>