# Suggest a simple Java math library for matrix operations for use with OpenGL (lwjgl) [closed]

I'm writing an OpenGL app with Java. I need to do some math for camera and frustum culling (for AABB). Could you suggest a simple and fast Java math library for that?

## closed as not constructive by MichaelHouse♦, Josh♦, TetradJan 4 '13 at 18:30

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

## 3 Answers

Vecmath from Java3d http://java.net/projects/vecmath is useful for standard 3d geometry stuff.

Not sure camera and frustum culling would really be a bottleneck, but if you use this heavily you should try to reuse things like Vector3f rather than calling new the whole time which can lead to costly garbage collection.

• mvnrepository.com/artifact/java3d/vecmath seems to have a more readily available jar. I'm not sure where this library is supposed to live these days, but I do think it is the library you want. – PeterT Jan 9 '12 at 16:45
• FWIW to any future readers, I'd now suggest looking into github.com/JOML-CI/JOML – PeterT Jun 16 '16 at 10:36

I'am the author of la4j library (Linar Algebra for Java). I've just released verion 0.3.0. Try to look at it. la4j works pretty fine now with sparse and dense matrices.

• -1: Your library does not seem to have any support for the requested features. Game-oriented matrix libraries tend to have far less "real linear algebra" features than la4j does, but do have a lot of specialized math for things like projection matrix generation, camera look-at matrix generation, etc. – Sean Middleditch Dec 28 '12 at 7:59

JAMA math.nist.gov/javanumerics/jama

Colt acs.lbl.gov/software/colt

jblas jblas.org

These come to mind first. jblas, thanks to the natives, seems to be a lot faster than the other though. Keep in mind the applet loader from LWJGL allow you to easily use natives in an applet.

• I believe these are not really designed for the kind of matrix maths one wants for 3d graphics; they are for operations on arbitrarily large matrices (like stats) rather than typical 3x3 or 4x4 geometric ones... unless I'm mistaken these libraries would be overcomplicated and suboptimal for simple graphic transformation kind of use-case. – PeterT Jan 9 '12 at 16:52
• If you are looking for pure speed you should use the natives. However, if you are looking for simplicity ("speed" as in "easy to understand and implement"), it may be a bit overkill. – Klems Jan 9 '12 at 17:32
• I doubt very much that native libraries designed to deal with large matrices will be more optimal than vecmath for these kinds of operations, HOWEVER... what you really want is something that can take advantage of native SIMD instructions on the CPU. AFAIK that isn't really practical in Java at present. Nonetheless, I maintain that your suggestions would be overcomplicated for the computer as well as the programmer... never a good combination. – PeterT Jan 11 '12 at 19:34