Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bytestring-net/mathio
Opinionated small scoped library for math used in other projects
https://github.com/bytestring-net/mathio
Last synced: about 1 month ago
JSON representation
Opinionated small scoped library for math used in other projects
- Host: GitHub
- URL: https://github.com/bytestring-net/mathio
- Owner: bytestring-net
- License: apache-2.0
- Created: 2023-08-05T17:54:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-02T21:15:47.000Z (about 1 year ago)
- Last Synced: 2024-08-09T13:14:36.298Z (5 months ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Mathio 🚀️
[![License](https://img.shields.io/badge/License-MIT%20or%20Apache%202-blue.svg?label=license)](./LICENSE-MIT)
[![crates.io](https://img.shields.io/crates/v/mathio.svg)](https://crates.io/crates/mathio)
[![Released API docs](https://docs.rs/mathio/badge.svg)](https://docs.rs/mathio)A ***lightweight***, ***simple*** and ***straight-forward*** opinionated library for **math** used in other projects.
Current features are:
* Fractions
* Tweening
* Periods### === Examples ===
**Fractions**
Great for expressing lossless floats
``` rust
use mathio::Fraction;let frac_1 = Fraction::new(2, 3);
let frac_2 = Fraction::new(3, 6);
assert_eq!(frac_1 + frac_2, Fraction::new(7, 6));
assert_eq!(frac_1 - frac_2, Fraction::new(1, 6));
assert_eq!(frac_1 * frac_2, Fraction::new(1, 3));
assert_eq!(frac_1 / frac_2, Fraction::new(4, 3));
assert_eq!(frac_1 >= frac_2, true);
```**Periods**
Good for clamping repeating values (angles, sin/cosine, etc.)
``` rust
let period = 360.0;
assert_eq!(315.0, periodical(period, -45.0));
assert_eq!(45.0, periodical(period, 45.0));
assert_eq!(0.0, periodical(period, 360.0));
assert_eq!(90.0, periodical(period, 450.0));
```### === Licensing ===
Released under both [APACHE](./LICENSE-APACHE) and [MIT](./LICENSE-MIT) licenses. Pick one that suits you the most!