Crates.io | lmaths |
lib.rs | lmaths |
version | 1.0.5 |
source | src |
created_at | 2022-03-27 12:26:06.930214 |
updated_at | 2022-04-08 16:48:37.587472 |
description | A short 2D Maths library |
homepage | https://github.com/Carbone13/lmaths |
repository | https://github.com/Carbone13/lmaths |
max_upload_size | |
id | 557247 |
size | 12,620 |
Short 2D Maths library. Currently implements Vector2 (64-bit floats) and Point2 (integer), with their classic functions such as length()
, normalize()
, dot()
etc...
Nothing fancy, just a good base for my projects.
Planning to implement other useful structs, like Matrices.
Examples :
Creating a Vector2 :
let v1 = Vector2::new(1.0, 5.6); //
// or using constants
let v2 = Vector2::ZERO; // (0.0, 0.0)
Same process for Point2 :
let p1 = Point2::new(-56, 45); //
// or using constants
let p2 = Point2::X_UNIT; // (1, 0)
Some demo for the functions :
let v3 = v1.normalized(); // won't modify v1
v1.normalize() // will modify v1
let dp = v1.dot(v2);
// or
let dp = Vector2::dot(v1, v2);