Crate angular_units

source ·
Expand description

Library for representing and manipulating angular quantities. Provides type-safe wrapper types for each unit as well as helper traits for abstracting over the concrete types. Conversions between types is easy and safe, allowing highly flexible manipulation.

Details

Arithmetic

Each angle type defines basic arithmetic operators. Multiplication and division are between an angle and a scalar. Addition and subtraction are between two angles and the two angles do not have to be represented using the same units for example, the following is valid:

let angle = Turns(0.25) + Deg(30.0) - ArcMinutes(15.0);

When combining units like this, the left-hand side type will be the result.

Normalization

For performance, most operations do not normalize the results or inputs automatically. This is mathematically sound, but it is often more convenient to have a single value to represent each angle. Thus, for methods that expect an angle within the standard domain, normalize() should be used to create an equivalent angle that is less than one period.

Structs

An angular quantity measured in arc minutes, which are 1/60th of a degree.
An angular quantity measured in arc seconds, which are 1/60th of an arc minute.
An angular quantity measured in degrees.
An angular quantity measured in gons.
An angular quantity measured in degrees.
An angular quantity measured in “turns”, or full rotations.

Traits

Base functionality for all angle types.
Construct Self from an angle.
A trait for linear interpolation between angles.
Construct an angle by converting from another type.

Functions

Compute the mean of a collection of angles.