#angle #geometry #degree #radians #trigonometry

no-std angle-sc

An angle represented by its sine and cosine

3 releases

0.1.2 Mar 18, 2024
0.1.1 Feb 16, 2024
0.1.0 Feb 11, 2024

#530 in Math

Download history 130/week @ 2024-02-13 65/week @ 2024-02-20 13/week @ 2024-02-27 14/week @ 2024-03-05 64/week @ 2024-03-12 90/week @ 2024-03-19 30/week @ 2024-03-26 19/week @ 2024-04-02

204 downloads per month
Used in 2 crates

MIT license

46KB
686 lines

angle-sc

crates.io docs.io License Rust codecov

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.

Unit circle
Figure 1 Unit circle formed by sin θ and cos θ

Design

Angle Class Diagram
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 UnitNegRanges:, 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 Angles.
The Validate trait is used to check that Angles and UnitNegRanges 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.

Dependencies

~0.8–1.4MB
~32K SLoC