Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Which math library do you recommend?  (Read 3553 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd

« JGO Bitwise Duke »

Medals: 519
Projects: 3
Exp: 8 years

« Posted 2012-02-08 11:00:51 »

I'm working on cleaning up my skeletal animation test program. I had planned to stop using LWJGL's built-in matrix and vector classes but I just haven't bothered to do so, but when I started with animation I realized how many lacking features there were, especially in the Quaternion class. Now I'm out hunting for a good math library.

Here is a list of features that I need. Functions in red are missing from LWJGL's math lib.
 - Matrix4x4 operations: translate by vector, multiply, invert.
 - Vector4 functions: transform by matrix
 - Quaternion functions: quat-quat multiplication, rotate vector by quaternion, slerp, quaternion to matrix conversion.

Performance related features:
 - No allocations. I'll be doing a lot of math for each bone, so being forced to allocate new objects all the time is going to increase GC stuttering quite a bit.
 - Everything is going into FloatBuffers in the end, so something similar to LWJGL's Matrix4f.load(floatBuffer) would be nice but not necessary.
 - I only need float precision these classes. Double precision would reduce performance and double the GPU bandwidth needed for an unnoticeable increase in precision.

Obviously I can survive with the LWJGL math lib, but I'd really like to start using a better one if possible. What do you guys use and recommend?

Offline Roquen
« Reply #1 - Posted 2012-02-08 11:22:37 »

I know of none I consider usable for gaming purposes.  I'd publish mine, but even I hate it.  I can give you sketches of the missing functionality if you desire (hey you already have direct rot vector by quat!)  WRT: SLERP - there are multiple ways to implement depending on how it's going to be used. Also I assume that by "quat to matrix" conversion that you really mean "quat rotation function to matrix".  Also exp & log are very useful for design purposes if you want to play around with curves in quaternion space (used for blending between animations...say walk -> run, etc.)

WRT: Bones I'd consider using quaternion/vector that manner you can choose to perform the rotation in the most efficient manner depending on the number of attachments at a given joint.  Also (maybe not worth the effort) one degree of freedom joints have a simpler quaternion formulation.  It's possible to use dual-quaternions (AKA Study quaternions, normalize Plucker coordinates) for generalized screw motions, wrenches, etc.  Or better yet find a working library (and tell me about it Wink )
Offline kappa
« League of Dukes »

JGO Kernel

Medals: 88
Projects: 15


« Reply #2 - Posted 2012-02-08 11:44:13 »

The javax.vecmath isn't a bad choice.


binary builds
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2012-02-08 11:50:51 »

javax quaternions are pretty broken, both for performance and accuracy...don't recall about the other types.
Offline Danny02
« Reply #4 - Posted 2012-02-08 12:43:39 »

why not build our own math libary, just copy past available code from different packages and make one big math libary for games.
I have published my math code in the showcase section, which has some more functions then the lwjgl libary but isn't that good on some other aspects.

We could just think of some best practises we what to have in our libary, like useing floatbuffers and having not many object allocations and so on and refactor exsiting code.
Offline Nate

« JGO Bitwise Duke »

Medals: 165
Projects: 4
Exp: 14 years

Esoteric Software

« Reply #5 - Posted 2012-02-08 13:03:37 »

libgdx Cheesy
It is actively developed. Everyone can always contribute to improve it!

Offline theagentd

« JGO Bitwise Duke »

Medals: 519
Projects: 3
Exp: 8 years

« Reply #6 - Posted 2012-02-08 13:51:46 »

Thanks for the suggestions everyone! I'll have to check up the ones you suggested more thoroughly before I make a decision though...

How is libgdx a math library? Does it have an util library that I can add to my game?

Offline kappa
« League of Dukes »

JGO Kernel

Medals: 88
Projects: 15


« Reply #7 - Posted 2012-02-08 14:11:06 »

How is libgdx a math library? Does it have an util library that I can add to my game?
It has a maths package which can easily be ripped out, seems really neat and clean too.

Another option you could try is OpenMaLi (Open Math Library) used by engines like Xith3D.
Offline lhkbob

JGO Knight

Medals: 32

« Reply #8 - Posted 2012-02-08 15:41:32 »

My math library avoids allocations and took its quaternion implementation from Bullet.  ATM it might have too many abstraction layers to allow for read-only types, but I'm considering changing it to have public fields and no interface/abstract types to emphasize performance.

Link is here:

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (23 views)
2015-07-27 16:38:00

Riven (13 views)
2015-07-27 15:35:20

Riven (18 views)
2015-07-27 12:26:13

Riven (8 views)
2015-07-27 12:23:39

BurntPizza (24 views)
2015-07-25 00:14:37

BurntPizza (36 views)
2015-07-24 22:06:39

BurntPizza (20 views)
2015-07-24 06:06:53

NoxInc (23 views)
2015-07-22 22:16:53

NoxInc (14 views)
2015-07-22 22:13:39

Jesse (36 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!