Maniphest T25700

2.56: Rotation Mode: Quaternion shows wrong orientation of the object
Closed, Resolved

Assigned To
Konrad Kleine (kwk)
Authored By
Sebastian Herholz (sherholz)
Jan 18 2011, 12:09 PM
Tags
  • Modifiers
  • BF Blender
Subscribers
Konrad Kleine (kwk)
Sebastian Herholz (sherholz)

Description

Patches: T25701

Hi,
First off all props for the Blender 2.5 development Team. I really love blender 2.5
Since I switched to the version 2.56/2.56a I realized that ther might be something wrong with the
calculations or handleing of the quaternions.
When I change the Rotation Mode of an Object from Euler XYZ or anything else to Quaternion.
The object changes its Orientation. The Quaternion presented in the GUI seems to be okay. But the orientation of the object is
messed up.

Here is a small example:
-open blender (you will se se standard cube in the middle)
-in the object propety change the rotation mode to Euler XYZ
- set X rotation to 45deg (Y and Z to 0.0) (see image1)
-change the rotation mode to Quaternion (quaterion presented is (w:0.924 x:0.383 y:0 z:0) which is a correct roation of 45deg around the X axis)
-you will see that the orientation of the object changes (image2)

This is a problem when setting up your scene using Quaternions cause what you se is not what you get.
This Problem also influences an exporter I am using to export blend scenes to ogre.

In blender 2.55 everything works fine.

Cheers

Sebastian

Event Timeline

Sebastian Herholz (sherholz) edited a custom field.Jan 18 2011, 12:09 PM
Sebastian Herholz (sherholz) attached 1 file(s): F16485: blend1.JPG.
Sebastian Herholz (sherholz) attached 1 file(s): F16487: blend2.JPG.
Konrad Kleine (kwk) added a comment.Jan 18 2011, 1:56 PM

Hi,

I have no experience in using quaternions in blender but one thing I do notice is that one can manipulate all the parameters (WXYZ) of the rotation quaternion. As far a I remember, if you want a quaternion to rotate some object, the quaternion needs to be normalized. If you mess with the rotation quaternion parameters you could end up with a quaternion that is not normalized. In fact in most cases you would need to renormalize it. Which is done automatically by blender when switching between Euler and Quaternion rotation type.

No back to your problem. I can confirm the behavior you described in a recent SVN build. And what is even more dramatic is this:

A quaternion rotation around 45 degrees is actually displayed as a rotation around 90 degrees. In fact a quaternion rotation around an arbitrary axis is applied with a double of the angle.

Here's how you can try it:

1) Open Blender with default cube scene.
2) In the object properties change the rotation type from "XYZ Euler" to "Quaternion (WXYZ)".
3) Switch to orthograpic side view (Hit NUMPAD3 and then NUMPAD5).
4) Rotate around the x axis with the mouse (Hit RKEY + XKEY and then move your mouse).
5) Watch the angle in the lower left side of the 3D view window as you move your mouse. And notice that if you roughly rotate around angle "alpha", "alpha/2" is displayed. You can also hit CTRLKEY to use stepwise rotation.

If you want you can repeat the same in "XYZ Euler" rotation mode and see that the indicated rotation is correct. Meanwhile I try to find out what's wrong with the quaternion rotation display and from where the angle number comes. In other words, which part of the code is responsible for displaying this number and where is it calculated it. My first searches brought me to "source/blender/blenlib/intern/math_rotation.c" but we'll see.

One last note: Since objects and armatures share the same rotation code you can easily repeat the behavior with a single armature bode. It'll also rotate twice the magnitude of the angle you've entered.

In other words: Sebastian, what you've found is a general error with quaternion calculation. Since a 45 degree rotation in quaternion mode currently is displayed as a 90 degree rotation, it looks like your cube's rotation is reset to zero rotation. But in fact it has rotated!!!

I hope this helps!

-Konrad-

Konrad Kleine (kwk) added a comment.Jan 18 2011, 1:59 PM

Sorry, I've made a few typos but here is an essential one. It had to be "2*alpha" instead of "alpha/2":

5) Watch the angle in the lower left side of the 3D view window as you move your mouse. And notice that if you roughly rotate around angle "alpha", "2*alpha" is displayed. You can also hit CTRLKEY to use stepwise rotation.

Konrad Kleine (kwk) added a comment.Jan 18 2011, 2:45 PM

I have created a patch that fixes this issue (http://projects.blender.org/tracker/index.php?func=detail&aid=25701&group_id=9&atid=127). There was a little typo error within the code (just one line).

Konrad Kleine (kwk) added a comment.Jan 18 2011, 4:04 PM

I've committed the patch to SVN and from revision 34390 on your bug should be fixed.

Konrad Kleine (kwk) added a comment.Jan 18 2011, 4:04 PM

Your reported issue has been fixed in SVN. Thanks for taking the
time to report!.

Konrad Kleine (kwk) changed the task status from Unknown Status to Resolved.Jan 18 2011, 4:04 PM
Konrad Kleine (kwk) added a comment.Jan 18 2011, 4:10 PM

Attached patch number to provide more info on the fix.

Sebastian Herholz (sherholz) added a comment.Jan 20 2011, 5:27 PM

hi Konrad,
Thx for the fast patch.
everything seems to work fine now.

Cheers

Sebastian