Hi everyone,

Since LWJGL 3 removed most of the functionality of the maths library, I thought I’d have a go at creating a Java-based equivalent to the C-based GLM library. Although a conceptual port of the GLM library already exists, I had some issues in getting it to work properly (lots of black screens). The library is fairly bare-bones at the moment, containing the most commonly-used functions, but it should be enough to get people started. I’m happy to take requests to extend it as well if you come across anything missing that you feel would be useful to others.

For reasons of flexibility, every function has an instance and static method (where it makes sense to do so). The instance method modifies the object itself (so myMatrix.transpose() will modify myMatrix directly), and the static method is more in line with what we had in LWJGL 2.9.x where you specify a source and a target matrix (so Matrix4f.transpose(myMatrix, newMatrix) will not modify myMatrix, and stores the results in newMatrix instead).

I’ve also avoided using local object declarations within the library, with the exception of lookAt which really needs it (at least until I have time to go through it step by step). It makes the code hard to read, but at least you know it’s not going to generate hundreds or thousands of collectible objects every frame, depending on what you’re doing

The library currently covers:

```
- Float and double precision 3x3 and 4x4 matrices and 2/3 component Vectors
- Quaternions
- Surface mathematics (calculating the normal, tangent, binormal)
- Camera mathematics (including versions of GLM's perspective, ortho and lookAt methods)
- Transformation utilities (such as generating a transformation matrix from supplied location, rotation and scale)
```

I’ll add to the library over time, but if you have any other requests then drop me a PM or reply to this thread. You can download the source and the library here:

Feel free to use the code however you want. Modify it, use it as a base, copy/paste bits, anything you like Hope someone finds this useful!

Commit History:

25th February 2015

- Kai has started adding double-precision alternatives to the float-based Matrix and Vector classes
- Added MatrixUtils for creating commonly-used matrices like the model matrix

18th February 2015

- New SurfaceMath class. Currently allows you to calculate the normal, tangent and binormal of a surface
- Surfaces are defined by 3 vertices and, in the case of the tangent and binormal, their corresponding UV coordinates
- Removed the normal method from Vector3f as SurfaceMath is a better home for it.
- New Vector2f class for 2D calculations

17th February 2015

- Added Quaternion.lookAt to generate a rotation towards at point B from point A (Thanks to SHC for suggesting it)
- Method allows for specification of the forward and up Vectors, or to use the defaults

16th February 2015

- Added Quaternion class for handling rotations

11th February 2015

- Fixed an issue with lookAt (thanks to Kai for the fix)

10th February 2015

- Added static alias-unsafe methods (mulFast, invertFast, transposeFast) which only work if the source and target matrices are different objects
- Added overloads for most static methods to take a FloatBuffer as the destination and write into it directly
- Removed the call to rewind() from the store() instance method in Matrix4f
- Re-wrote lookAt to remove local Vector3fs (only local primitive floats are used). The code is now almost totally illegible but initial testing suggests it works
- Some other minor optimisations (such as removing calls to set() from methods that don’t require it)

9th February 2015

- Added alias safety, thanks Kai for pointing that one out

8th February 2015

- Initial Build