angle-sc
An angle represented by its sine and cosine.
The cosine and sine of angle θ can be viewed as x and y coordinates,
with θ measured anti-clockwise from the x axis.
They form a unit circle, see Figure 1.
Figure 1 Unit circle formed by sin θ and cos θ
Design
Figure 2 Angle Class Diagram
The Angle
on the opposite
side of the unit circle is calculated by simply
negating the sin and cos of Angle
.
Angle
addition and subtraction are performed using
angle sum and difference identities.
Angle
double
uses the double-angle formulae
and half
uses the half-angle formulae.
The Angle
<
operator compares whether an Angle
is clockwise of the other
Angle
on the unit circle.
The sin
and cos
fields of Angle
are UnitNegRange
s:,
a newtype
with values in the range -1.0 to +1.0 inclusive.
The Degrees
and Radians
newtypes are used to convert to and from Angle
s.
The Validate
trait is used to check that Angle
s and UnitNegRange
s are valid.
The library is declared no_std so it can be used in embedded applications.
Contribution
If you want to contribute through code or documentation, the Contributing guide is the best place to start. If you have any questions, please feel free to ask. Just please abide by our Code of Conduct.
License
angle-rs
is provided under a MIT license, see LICENSE.