Super fast rotXYZ

As I was trying to understand better matrices, rotations, quaternions and the lot, I came across the following algorithm which is better than the one used by Transform3D. I’ll put here, because people might want to use it instead. Perhaps, it should go to Xith but I’m still not sure how to suggest changes (should everything go to bugzilla?)


ax = angle along x
ay = angle along y
az = angle along z

instead of trans.rot(ax, ay, az), use: 

                      float A       = (float)Math.cos(ax);
                      float B       = (float)Math.sin(ax);
                    float C       = (float)Math.cos(ay);
                float D       = (float)Math.sin(ay);
                float E       = (float)Math.cos(az);
                float F       = (float)Math.sin(az);

                float AD      =   A * D;
                float BD      =   B * D;

                Matrix3f mat = new Matrix3f();
                mat.m00  =   C * E;
                mat.m01  =  -C * F;
                mat.m02  =  -D;
                mat.m10  = -BD * E + A * F;
                mat.m11  =  BD * F + A * E;
                mat.m12  =  -B * C;
                mat.m20  =  AD * E + B * F;
                mat.m21  = -AD * F + B * E;
                mat.m22 =   A * C;
    

                rot.setRotation(mat);


I’ll quote from http://www.flipcode.com/documents/matrfaq.html:

“Using basic matrix calculations, the operation count would reach 128 multiplications, 96 additions and 80 assignments operations.
Using the optimised algorithm, only 12 multiplications, 6 subtractions
and 18 assignment operations are required.
So, it is obvious that by using the optimised algorithm, a performance achievement of 1000% is achieved!”

1000% :o !!

[quote]Perhaps, it should go to Xith but I’m still not sure how to suggest changes (should everything go to bugzilla?)
[/quote]
Yes. You can open an issue and attach a patch to it (note that you have to create the issue, before you can add a patch).