``` 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
```
```/*!
[![Crate](https://img.shields.io/crates/v/fts_gamemath.svg)](https://crates.io/crates/fts_gamemath)
[![Build Status](https://travis-ci.org/forrestthewoods/fts_gamemath.svg?branch=master)](https://travis-ci.org/forrestthewoods/fts_gamemath)
![Crates.io](https://img.shields.io/crates/l/fts_gamemath.svg)

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

# fts_units

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

```no_compile
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.

```rust
use fts_units::si_system::quantities::*;
# use fts_units::ops::Sqrt;

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());
range
}
```

You can convert between units and cast between types.

```rust
# use fts_units::si_system::quantities::*;
# use fts_units::quantity::{CastAmount, ConvertUnits, Quantity};

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](https://docs.rs/fts_units/).

# fts_vecmath
Coming soon!

# fts_intersect3d
Coming soon!
*/
```