6 stable releases
1.0.5 | Apr 8, 2022 |
---|---|
1.0.4 | Apr 6, 2022 |
1.0.1 | Mar 27, 2022 |
#1612 in Math
Used in lgeo
12KB
442 lines
L-Maths
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);