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
Traits
Self
from an angle.