pub trait FloatingScalar: Scalar + Mul<Output = Self> + Neg<Output = Self> {
    const TAU: Self;
    const PI: Self;
    const EPSILON: Self;

    // Required methods
    fn sqrt(self) -> Self;
    fn cos(self) -> Self;
    fn sin(self) -> Self;
    fn atan2(self, other: Self) -> Self;

    // Provided methods
    fn square(self) -> Self { ... }
    fn tan(self) -> Self { ... }
    fn lerp(self, other: Self, t: Self) -> Self { ... }
    fn angle_as_vector(self) -> [Self; 2] { ... }
    fn is_zero(self) -> bool { ... }
    fn is_near_zero(self, n: Self) -> bool { ... }
}
Expand description

Trait for floating-point scalar numbers

Required Associated Constants§

source

const TAU: Self

The value of Tau, or 2π

source

const PI: Self

The value of π

source

const EPSILON: Self

The epsilon value

Required Methods§

source

fn sqrt(self) -> Self

Get the sqare root of the scalar

source

fn cos(self) -> Self

Get the cosine

source

fn sin(self) -> Self

Get the sine

source

fn atan2(self, other: Self) -> Self

Get the four-quadrant arctangent

Provided Methods§

source

fn square(self) -> Self

Square the scalar

source

fn tan(self) -> Self

Get the tangent

source

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

Linear interpolate the scalar with another

source

fn angle_as_vector(self) -> [Self; 2]

Get the unit vector corresponding to an angle in radians defined by the scalar

source

fn is_zero(self) -> bool

Check if the value is within its epsilon range

source

fn is_near_zero(self, n: Self) -> bool

Check if the value is within a multiple epsilon range

Implementations on Foreign Types§

source§

impl FloatingScalar for f32

source§

const PI: Self = 3.14159274f32

source§

const TAU: Self = 6.28318548f32

source§

const EPSILON: Self = 1.1920929E-7f32

source§

fn sqrt(self) -> Self

source§

fn cos(self) -> Self

source§

fn sin(self) -> Self

source§

fn atan2(self, other: Self) -> Self

source§

impl FloatingScalar for f64

source§

const PI: Self = 3.1415926535897931f64

source§

const TAU: Self = 6.2831853071795862f64

source§

const EPSILON: Self = 2.2204460492503131E-16f64

source§

fn sqrt(self) -> Self

source§

fn cos(self) -> Self

source§

fn sin(self) -> Self

source§

fn atan2(self, other: Self) -> Self

Implementors§