Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tguichaoua/angulus
Unit agnostic angle in rust.
https://github.com/tguichaoua/angulus
helper mathematics rust
Last synced: 15 days ago
JSON representation
Unit agnostic angle in rust.
- Host: GitHub
- URL: https://github.com/tguichaoua/angulus
- Owner: tguichaoua
- License: apache-2.0
- Created: 2022-08-30T15:19:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T16:09:30.000Z (about 1 year ago)
- Last Synced: 2024-12-01T16:43:29.583Z (25 days ago)
- Topics: helper, mathematics, rust
- Language: Rust
- Homepage:
- Size: 118 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# angulus
[](https://github.com/tguichaoua/angulus)
[](https://crates.io/crates/angulus)
[](https://docs.rs/angulus)
[](https://github.com/rust-lang/rust/releases/tag/1.61.0)Unit agnostic angle.
## What problem does it solve ?
Using simple floating point numbers to store an angle value is error-prone : you may add two angle with one in radians and the second in degrees or you may try to compute the cosine of a value in degrees and get an unexpected result.
`angulus` provides a type that represent an angle with no specific unit.
## Example
```rust
use angulus::{Angle, ToAngle};
use angulus::units::Degrees;// Create an angle of 90°.
let alpha = 90.0_f32.deg();// Create an angle of π/4 rad (45°).
let beta = Angle::RAD_FRAC_PI_4;// Add the two angle without worrying about units.
let gamma = alpha + beta;// Print the result.
println!(
"The cosine of {} is {}",
Degrees(gamma), // The angle is wrapped to display the value in degrees.
gamma.cos() // Compute the cosine without worrying about units.
);// Output : The cosine of 135° is -0.70710677
```## Features
- `std`: by default angulus links to the standard library. Disable this feature to remove this dependency and be able to use angulus in `#![no_std]` crates.
- `libm`: use the [libm crate](https://docs.rs/libm/latest/libm/) for the math methods (sin, cos, tan) when `std` is disabled.
- `serde`: enable serialization and deserialization with the [serde crate](https://docs.rs/serde/latest/serde/).
- `rand`: enable generation of random angle with the [rand crate](https://docs.rs/rand/latest/rand/).## Minimum Supported Rust Version
This crate requires Rust 1.61.0 or later.
## License
Licensed under either of the following, at your choice:
- [Apache License, Version 2.0](https://github.com/tguichaoua/angulus/blob/main/LICENSE-APACHE), or
- [MIT license](https://github.com/tguichaoua/angulus/blob/main/LICENSE-MIT)Unless explicitly stated otherwise, any contribution intentionally submitted
for inclusion in this crate, as defined in the Apache-2.0 license, shall
be dual-licensed as above, without any additional terms or conditions.