As I was working on my own game framework, I decided to decouple the math source on its own library:
GitHub link
Documentation:
https://github.com/ferreiradaselva/mathc/blob/master/REFERENCE.md
This is mainly for OpenGL.
Features
- 2D vectors
- 3D vectors
- Quaternions
- Matrices
- Easing functions
Planned Features
Currently the library reached the first major release, but I'm adding features that don't break compatibility, and suggestions for features that break compatibility are welcome, saved for the next major release (2.0.0).
The next feature I'm planning is detection for 2D and 3D primitives (circles, lines and triangles, both 2D and 3D).
Pointers vs. Values
There are two versions of the same function, one that take pointer arguments and other that take value arguments:
| pmatrix_look_at(&pos, &target, &view);
view = matrix_look_at(pos, target);
|
Other examples in the GitHub page.
Taking pointers is certainly faster, but you can use the function that take values if performance is not critical for you, as they are more readable.
Single Vector Structure
There's only one vector structure, used for 2D vectors, 3D vectors and quaternions. When I had to use 2D vectors, sometimes I would want to use them as 3D vectors and vice-versa. So I decided to use the same structure to make this possible.
Easing Functions
The easing functions are great for animations: it makes easier to make smooth and organic motions.
Why another math library?
This is not intended to be a competitor with other math libraries, but a small and simple alternative.