Trait acgmath::Angle [] [src]

pub trait Angle where
    Self: Copy + Clone,
    Self: PartialEq + PartialOrd,
    Self: ApproxEq<Epsilon = Self::Unitless>,
    Self: Zero,
    Self: Neg<Output = Self>,
    Self: Add<Self, Output = Self>,
    Self: Sub<Self, Output = Self>,
    Self: Rem<Self, Output = Self>,
    Self: Mul<Self::Unitless, Output = Self>,
    Self: Div<Self, Output = Self::Unitless>,
    Self: Div<Self::Unitless, Output = Self>, 
{ type Unitless: BaseFloat; fn full_turn() -> Self; fn sin(self) -> Self::Unitless; fn cos(self) -> Self::Unitless; fn tan(self) -> Self::Unitless; fn sin_cos(self) -> (Self::Unitless, Self::Unitless); fn asin(ratio: Self::Unitless) -> Self; fn acos(ratio: Self::Unitless) -> Self; fn atan(ratio: Self::Unitless) -> Self; fn atan2(a: Self::Unitless, b: Self::Unitless) -> Self; fn normalize(self) -> Self { ... } fn opposite(self) -> Self { ... } fn bisect(self, other: Self) -> Self { ... } fn turn_div_2() -> Self { ... } fn turn_div_3() -> Self { ... } fn turn_div_4() -> Self { ... } fn turn_div_6() -> Self { ... } fn csc(self) -> Self::Unitless { ... } fn cot(self) -> Self::Unitless { ... } fn sec(self) -> Self::Unitless { ... } }

Angles and their associated trigonometric functions.

Typed angles allow for the writing of self-documenting code that makes it clear when semantic violations have occured - for example, adding degrees to radians, or adding a number to an angle.

Associated Types

Required Methods

A full rotation.

Compute the sine of the angle, returning a unitless ratio.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::sin(angle);

Compute the cosine of the angle, returning a unitless ratio.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::cos(angle);

Compute the tangent of the angle, returning a unitless ratio.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::tan(angle);

Compute the sine and cosine of the angle, returning the result as a pair.

This does not have any performance benefits, but calculating both the sine and cosine of a single angle is a common operation.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let (s, c) = Rad::sin_cos(angle);

Compute the arcsine of the ratio, returning the resulting angle.

use acgmath::prelude::*;
use acgmath::Rad;

let angle: Rad<f32> = Rad::asin(0.5);

Compute the arccosine of the ratio, returning the resulting angle.

use acgmath::prelude::*;
use acgmath::Rad;

let angle: Rad<f32> = Rad::acos(0.5);

Compute the arctangent of the ratio, returning the resulting angle.

use acgmath::prelude::*;
use acgmath::Rad;

let angle: Rad<f32> = Rad::atan(0.5);

Provided Methods

Return the angle, normalized to the range [0, full_turn).

Return the angle rotated by half a turn.

Returns the interior bisector of the two angles.

Half of a full rotation.

A third of a full rotation.

A quarter of a full rotation.

A sixth of a full rotation.

Compute the cosecant of the angle.

This is the same as computing the reciprocal of Self::sin.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::csc(angle);

Compute the cotangent of the angle.

This is the same as computing the reciprocal of Self::tan.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::cot(angle);

Compute the secant of the angle.

This is the same as computing the reciprocal of Self::cos.

use acgmath::prelude::*;
use acgmath::Rad;

let angle = Rad(35.0);
let ratio: f32 = Rad::sec(angle);

Implementors