### 10 releases (6 breaking)

Uses new Rust 2021

0.6.0 | Oct 6, 2022 |
---|---|

0.5.0 | Aug 11, 2022 |

0.4.0 | Aug 11, 2022 |

0.3.1 | Aug 10, 2022 |

0.0.3 | Aug 6, 2022 |

#**256** in Math

**MIT/Apache**

30KB

635 lines

# Mathie

## Overview

Mathie is a rust math type library which contains the 3 basic types for doing anything 2D.

A single number value.`Value`

A two-dimensional position.`Vec2`

A two-dimensional area that has an origin and a size.`Rect`

## Math

Doing math with the builtin types is designed to be simple and powerful. All of them support Addition, Subtraction, Multiplication, Division and Remainder.

`fn` `add``(``)`` ``{`
`assert_eq!``(``Vec2D``::`new`(``0.``5``,` `0.``5``)` `+` `Vec2D``::`new`(``1.``0``,` `1.``0``)``,` `Vec2D``::`new`(``1.``5``,` `1.``5``)``)``;`
`assert_eq!``(``Vec2D``::`new`(``0.``5``,` `0.``5``)` `+` `1.``0``,` `Vec2D``::`new`(``1.``5``,` `1.``5``)``)``;`
`}`

## Units

This library runs on the optional concept of units which may be sized and are designed to be easily converted between without thinking about it.

`fn` `cm_to_m``(``)`` ``{`
`let` v0 `=` `Vec2D``::``<``f32`, Centimeter`>``::`new_def`(``250.``0``,` `250.``0``)``;`
`//` () is base unit. In all cases its Meter
`let` v1 `=` v0`.``convert``::``<``(``)``>``(``)``;`
`assert_eq!``(`v1`,` `Vec2D``::`new_def`(``2.``5``,` `2.``5``)``)``;`
`}`

There are builtin units that are optional.

20 Metric prefixes`metric_units`

10 Imperial prefixes`imperial_units`

Nautical mile`nautical_units`

## Compatibility

This library has optional features for compatibility between other
math type libraries like

.`euclid`

`fn` `euclid_compat``(``)`` ``{`
`let` `_``:` `Vec2D``<``f32`, `(``)``>` `=` `euclid``::``Vector2D``::`new`(``1.``0``,` `1.``0``)``.``into``(``)``;`
`}`

#### Dependencies

~100–425KB