Skip to content
A collection of Rust libraries to provide common 3d math utilities for video games.
Branch: master
Clone or download
Latest commit 39ad517 Jun 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Hide ignored folders in vscode May 20, 2019
examples Ran cargo fmt Jun 10, 2019
fts_units Bump patch Jun 12, 2019
src Add license badge Jun 12, 2019
tests Ran cargo fmt Jun 10, 2019
.gitignore Move to workspace model Nov 13, 2018
.travis.yml Travis config update. Jun 12, 2019
Cargo.toml Bump patch Jun 12, 2019
LICENSE Simply license to single file Nov 19, 2018 Add license badge Jun 12, 2019


Crate API Build Status

fts_gamemath is a collection of Rust crates that provide basic building blocks for 3d video game math


fts_units is a Rust library that enables compile-time type-safe mathematical operations using units of measurement.

use fts_units::si_system::quantities::f32::*;
let d = Meters::new(10.0);
let t = Seconds::new(2.0);
let v = d / v; // units will be m·s⁻¹
let err = d + t; // compile error

This easily extends into complex operations.

use fts_units::si_system::quantities::*;

fn calc_ballistic_range(speed: MetersPerSecond<f32>, gravity: MetersPerSecond2<f32>, initial_height: Meters<f32>)
-> Meters<f32>
    let d2r = 0.01745329252;
    let angle : f32 = 45.0 * d2r;
    let cos = Dimensionless::<f32>::new(angle.cos());
    let sin = Dimensionless::<f32>::new(angle.sin());

    let range = (speed*cos/gravity) * (speed*sin + (speed*speed*sin*sin + Dimensionless::<f32>::new(2.0)*gravity*initial_height).sqrt());

You can convert between units and cast between types.

let m = Meters::<f32>::new(7.73);
let km : Kilometers<f32> = m.convert_into();
assert_eq!(km.amount(), 0.00773);

let i : Meters<i32> = m.cast_into();
assert_eq!(i.amount(), 7);

For additional features and examples refer to the fts_units documentation.


Coming soon!


Coming soon!

License: Unlicense OR MIT

You can’t perform that action at this time.