#math #statistics #vector #quaternions #trigonometry

no-std micromath

Embedded-friendly math library featuring fast floating point approximations (with small code size) for common arithmetic operations, trigonometry, 2D/3D vector types, statistical analysis, and quaternions. Optimizes for performance and small code size at the cost of precision

12 releases (1 stable)

✓ Uses Rust 2018 edition

1.0.0 Dec 3, 2019
0.5.1 Nov 28, 2019
0.4.1 Oct 8, 2019
0.3.1 May 11, 2019
0.0.1 Apr 28, 2019

#46 in Embedded development

Download history 76/week @ 2019-08-20 20/week @ 2019-08-27 34/week @ 2019-09-03 14/week @ 2019-09-10 80/week @ 2019-09-17 34/week @ 2019-09-24 66/week @ 2019-10-01 56/week @ 2019-10-08 34/week @ 2019-10-15 100/week @ 2019-10-22 76/week @ 2019-10-29 21/week @ 2019-11-05 224/week @ 2019-11-12 32/week @ 2019-11-19 53/week @ 2019-11-26

267 downloads per month
Used in 4 crates (1 directly)

Apache-2.0 OR MIT

195KB
2K SLoC

Crate Docs Build Status Safety Dance MSRV Apache 2.0/MIT Licensed Gitter Chat

Embedded-friendly (i.e. no_std) Rust math library featuring fast, safe floating point approximations for common arithmetic operations, trigonometry, 2D/3D vector types, statistical analysis, and quaternions.

Optimizes for performance and small code size at the cost of precision.

Documentation

Requirements

Requires Rust 1.31 or newer.

In the future, we reserve the right to change the following:

  • Minimum Supported Rust Version
  • generic-array version (presently ^0.13)

i.e. these are explicitly out of scope for the SemVer guarantees this crate provides.

However, when we change either of these things, we will accompany them with a minor version bump.

Features

Comparisons with other Rust crates

libm crate

The libm crate contains a port of MUSL's libm to Rust, providing high-precision implementations of common arithmetic functions.

micromath trades precision for performance, instead using the best-available approximations of the same functions, implemented using safe conversions between f32 and u32.

The approximations are generally calculated using a combination of bit twiddling and magic constants, as opposed to the FPU-heavy approaches used by libm. These approaches are culled from recent academic research papers as well as older approaches which have been commonly used in games and other performance critical use cases where approximations are adequate.

vek crate

The vek crate provides a rich library for 2D and 3D vector types. Unfortunately, due to a number of issues including a transitive std dependency through the approx crate, vek does not support no_std. According to the crate's author, the potential fixes are nontrivial (and involve addressing problems such as transcendantal functions causing overflow panics).

micromath has been written from the ground up to support no_std use cases. In fact, it doesn't even have a std feature!

Code of Conduct

We abide by the Contributor Covenant and ask that you do as well.

For more information, please see CODE_OF_CONDUCT.md.

License

Copyright © 2019 NeoBirth Developers

Dual licensed under your choice of either of:

Incorporates portions of some tests from the libm crate. Copyright © 2018 Jorge Aparicio and also dual licensed under the Apache 2.0 and MIT licenses.

Dependencies