Fast 4x4 matrix multiplication in Java with NIO float buffers
Posted
by kayahr
on Stack Overflow
See other posts from Stack Overflow
or by kayahr
Published on 2010-05-09T11:26:13Z
Indexed on
2010/05/09
11:38 UTC
Read the original article
Hit count: 323
I know there are LOT of questions like that but I can't find one specific to my situation. I have 4x4 matrices implemented as NIO float buffers (These matrices are used for OpenGL). Now I want to implement a multiply method which multiplies Matrix A with Matrix B and stores the result in Matrix C. So the code may look like this:
class Matrix4f
{
private FloatBuffer buffer = FloatBuffer.allocate(16);
public Matrix4f multiply(Matrix4f matrix2, Matrix4f result)
{
{{{result = this * matrix2}}} <-- I need this code
return result;
}
}
What is the fastest possible code to do this multiplication? Some OpenGL implementations (Like the OpenGL ES stuff in Android) provide native code for this but others doesn't. So I want to provide a generic multiplication method for these implementations.
© Stack Overflow or respective owner