8 releases
0.2.1 | Jul 21, 2023 |
---|---|
0.2.0 | Jun 11, 2023 |
0.1.5 | May 23, 2023 |
0.1.4 | Apr 17, 2023 |
0.1.1 | Oct 24, 2021 |
#618 in Math
Used in lox
195KB
3.5K
SLoC
lina
: linear algebra library for 3D applications
lina
is a linear algebra library making heavy use of strong typing.
Its focus is on 3D applications like games, i.e. low-dimensional vectors and matrices.
Notable features setting lina
apart from other similar libraries:
- Usage of const generics, while still allowing scalar access via
.x
,.y
,.z
and.w
. - Separate types for homogeneous coordinates (
HcPoint
andHcMatrix
). - Most types have a
Space
parameter to represent the logical space (e.g. model, world, view, ... space) the vector, point, etc lives in. - Distinction between locations (
Point
) and displacements (Vector
).
The last three of these illustrate the philosophy of lina
regarding strong typing.
For motivation and examples, please read this document.
In fact, this is all still a bit of an experiment, but so far I am very happy with the results in practice!
However, I'm sure this is not for everyone and many would prefer a different API.
Luckily, there exist many other libraries in the Rust ecosystem.
To be clear: lina
is not better than
cgmath
,
nalgebra
,
glam
,
ultraviolet
vek
, etc.
It is simply different, with an API that better fits my taste – and maybe yours.
Additional Features:
- Vectors, points, matrices
- Commonly used transformation matrices
- Operators overloaded as you would expect
- Strongly typed angles:
Degrees
andRadians
- Spherical coordinates:
SphericalPos
andSphericalDir
- Several helper functions:
atan2
,clamp
,lerp
,slerp
, ... - Approximate float equality (including
assert_approx_eq!
)
The only major thing that I'd still like to add in the future is rotors.
lina
offers the standard translation matrices, but rotors can be better for representing and composing rotations.
See the documentation for more information.
Status of this project
lina
is is certainly usable and is quite feature rich.
I actively use it in a game project, which also motivated most API design decisions.
But lina
is not used by many other projects, and there might still be some non-minor API changes.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~290KB