[SOLVED]Quaterion to Matrix and back conversion issues
Posted: Thu Dec 19, 2013 1:53 pm
Dear Bullet community,
I am trying to integrate a model for simulating 1D flexible bodies (ropes, wires etc.) into Bullet. The model is based on a Cosserat Theory, specifically on this paper (http://cg.informatik.uni-freiburg.de/pu ... _ropes.pdf). The implementation uses quaternions internally and employs symbolic differentiation software (Maple) to differentiate energy into restitution forces and torques which are later integrated using semi-implicit Euler scheme.
Unfortunately, the model running in Bullet easily explodes in a 100% reproducible manner. After a few days of debugging and eliminating out all the possible differences between Bullet and our reference implementation it turned out that the reason is the conversion from quaternions to matrices and vice versa during position integration (Transform.set/getRotation()). Our reference implementation stores orientations as quaternions and does all the calculations using then so such a conversion is not needed. Bullet stores orientations as matrices which are converted to quaternions for angular velocity integration and then the obtained orientation is converted back to matrix and stored.
I made a quick test using our reference implementation where for a few seconds a rod is spinning in different directions in a free space. During the integration the quaternion is converted to a matrix and immediately back using methods extracted from Bullet (Transform.set/getRotation()). The difference in x,y,z,w componenets is compared against a reference i.e. not converted quaternion which is used in the simulation. I attached the excel file and chart with the results. My model obviously explodes at the first peak. It is clearly visible that some values are compensated by other values but for some oriantations this is flipped. I also used other methods I found on the internet to do the conversion but the results are similar.
I would really appreciate your help guys. I want to extend my model with collisions and constraints but would like to avoid reinventing a wheel. The model itself would also be a nice contribution to Bullet. It is based on a solid theoretical footing and reproduces not only stretch and bend of the rod but also material torsion resulting in looping phenomenom, see here http://cg.informatik.uni-freiburg.de/pe ... /corde.htm.
Thanks in advance
Kay
EDIT: I have added the difference against the angle in degrees by spinning the rod just in one plane (only X and W components change and X angle)
I am trying to integrate a model for simulating 1D flexible bodies (ropes, wires etc.) into Bullet. The model is based on a Cosserat Theory, specifically on this paper (http://cg.informatik.uni-freiburg.de/pu ... _ropes.pdf). The implementation uses quaternions internally and employs symbolic differentiation software (Maple) to differentiate energy into restitution forces and torques which are later integrated using semi-implicit Euler scheme.
Unfortunately, the model running in Bullet easily explodes in a 100% reproducible manner. After a few days of debugging and eliminating out all the possible differences between Bullet and our reference implementation it turned out that the reason is the conversion from quaternions to matrices and vice versa during position integration (Transform.set/getRotation()). Our reference implementation stores orientations as quaternions and does all the calculations using then so such a conversion is not needed. Bullet stores orientations as matrices which are converted to quaternions for angular velocity integration and then the obtained orientation is converted back to matrix and stored.
I made a quick test using our reference implementation where for a few seconds a rod is spinning in different directions in a free space. During the integration the quaternion is converted to a matrix and immediately back using methods extracted from Bullet (Transform.set/getRotation()). The difference in x,y,z,w componenets is compared against a reference i.e. not converted quaternion which is used in the simulation. I attached the excel file and chart with the results. My model obviously explodes at the first peak. It is clearly visible that some values are compensated by other values but for some oriantations this is flipped. I also used other methods I found on the internet to do the conversion but the results are similar.
I would really appreciate your help guys. I want to extend my model with collisions and constraints but would like to avoid reinventing a wheel. The model itself would also be a nice contribution to Bullet. It is based on a solid theoretical footing and reproduces not only stretch and bend of the rod but also material torsion resulting in looping phenomenom, see here http://cg.informatik.uni-freiburg.de/pe ... /corde.htm.
Thanks in advance
Kay
EDIT: I have added the difference against the angle in degrees by spinning the rod just in one plane (only X and W components change and X angle)