# [−][src]Trait cgmath::prelude::Angle

    pub trait Angle where
        Self: Copy + Clone,
        Self: PartialEq + PartialOrd,
        Self: AbsDiffEq<Epsilon = Self::Unitless>,
        Self: RelativeEq<Epsilon = Self::Unitless>,
        Self: UlpsEq<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>,
        Self: Sum, {
        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 normalize_signed(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

### `type Unitless: BaseFloat`

Loading content...

## Required methods

### `fn full_turn() -> Self`

A full rotation.

### `fn sin(self) -> Self::Unitless`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn cos(self) -> Self::Unitless`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn tan(self) -> Self::Unitless`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn sin_cos(self) -> (Self::Unitless, Self::Unitless)`

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 cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn asin(ratio: Self::Unitless) -> Self`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn acos(ratio: Self::Unitless) -> Self`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn atan(ratio: Self::Unitless) -> Self`

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn atan2(a: Self::Unitless, b: Self::Unitless) -> Self`

Loading content...

## Provided methods

### `fn normalize(self) -> Self`

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

### `fn normalize_signed(self) -> Self`

Return the angle, normalized to the range `[-turn_div_2, turn_div_2)`.

### `fn opposite(self) -> Self`

Return the angle rotated by half a turn.

### `fn bisect(self, other: Self) -> Self`

Returns the interior bisector of the two angles.

### `fn turn_div_2() -> Self`

Half of a full rotation.

### `fn turn_div_3() -> Self`

A third of a full rotation.

### `fn turn_div_4() -> Self`

A quarter of a full rotation.

### `fn turn_div_6() -> Self`

A sixth of a full rotation.

### `fn csc(self) -> Self::Unitless`

Compute the cosecant of the angle.

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn cot(self) -> Self::Unitless`

Compute the cotangent of the angle.

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

### `fn sec(self) -> Self::Unitless`

Compute the secant of the angle.

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

    use cgmath::prelude::*;
    use cgmath::Rad;

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

Loading content...

## Implementors

### `impl<S: BaseFloat> Angle for Deg<S>`[src]

#### `type Unitless = S`

#### `fn full_turn() -> Deg<S>`[src]

#### `fn sin(self) -> S`[src]

#### `fn cos(self) -> S`[src]

#### `fn tan(self) -> S`[src]

#### `fn sin_cos(self) -> (S, S)`[src]

#### `fn asin(a: S) -> Deg<S>`[src]

#### `fn acos(a: S) -> Deg<S>`[src]

#### `fn atan(a: S) -> Deg<S>`[src]

#### `fn atan2(a: S, b: S) -> Deg<S>`[src]

### `impl<S: BaseFloat> Angle for Rad<S>`[src]

#### `type Unitless = S`

#### `fn full_turn() -> Rad<S>`[src]

#### `fn sin(self) -> S`[src]

#### `fn cos(self) -> S`[src]

#### `fn tan(self) -> S`[src]

#### `fn sin_cos(self) -> (S, S)`[src]

#### `fn asin(a: S) -> Rad<S>`[src]

#### `fn acos(a: S) -> Rad<S>`[src]

#### `fn atan(a: S) -> Rad<S>`[src]

#### `fn atan2(a: S, b: S) -> Rad<S>`[src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)