Unnecessary Quaternion to Matrix transform in leapfrogAsphericalRotate
I was going through the source code, and in the function leapfrogAsphericalRotate
of the Newton integrator I noticed that there's an unnecessary quaternion to matrix conversion.
Matrix3r A=state->ori.conjugate().toRotationMatrix(); // rotation matrix from global to local r.f.
I changed that to
Quaternionr A=state->ori.conjugate(); // rotation from global to local r.f.
And everything seems to work well. The code does not modify A, so it could also be a const Quaternionr
. I ran yade --checkall, and everything passed, except for checkJCFpm.py. But that test failed with the normal implementation too, so I don't think that's because of the change. I cloned the trunk branch today and that's what I'm using to test.
Using the matrix, although not a big deal, can create small numerical errors from the conversion, and in very rare cases, I believe it could cause a gimbal lock. I suggest changing this. Also, A few lines afterward rotations are made with the quaternion instead of the matrix.
If you allow me to, I can do the merge request.