I know that there are many such questions, but I canβt find one that concerns my situation. I have 4x4 matrices implemented as NIO floating point buffers (these matrices are used for OpenGL). Now I want to implement a multiplication method that multiplies matrix A by matrix B and stores the result in matrix C. Thus, 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 code for this multiplication? Some versions of OpenGL (like the OpenGL ES files in Android) contain native code for this, while others do not. Therefore, I want to provide a general multiplication method for these implementations.
source
share