# Quaternions xz rotation with preserved y

• Jan 3rd 2008, 09:32 AM
sjcomp
Quaternions xz rotation with preserved y
Before we go into math this is the common life explanation of the problem that I try to simulate: I have a piece of a tape (thin, wide, and long). One end of it is attached to a surface with a pin (tape can rotate around the pin). I can move the other end of the tape around as I wish. I'm using quaternions to calculate the rotation of the tape. But there is a problem shown in the illustration:
http://img133.imageshack.us/img133/6...tapefg2.th.jpg
When I move the free end point around, the tape rotates around Y axis (around the axis that goes through its long side). I would like to get rid of this rotation. If you imagine this tape laying flat on the table, when I move the end point around, the tape is not laying flat anymore, but could be standing on its side.
So this is the question: How do I control the rotation along Y axis in a quaternion?
(I can supply the details on how I actually come up with quaternion that represents this partially wrong result, if that is of any help)
Thanks a lot.
• Jan 3rd 2008, 12:38 PM
topsquark
Quote:

Originally Posted by sjcomp
Before we go into math this is the common life explanation of the problem that I try to simulate: I have a piece of a tape (thin, wide, and long). One end of it is attached to a surface with a pin (tape can rotate around the pin). I can move the other end of the tape around as I wish. I'm using quaternions to calculate the rotation of the tape. But there is a problem shown in the illustration:
http://img133.imageshack.us/img133/6...tapefg2.th.jpg
When I move the free end point around, the tape rotates around Y axis (around the axis that goes through its long side). I would like to get rid of this rotation. If you imagine this tape laying flat on the table, when I move the end point around, the tape is not laying flat anymore, but could be standing on its side.
So this is the question: How do I control the rotation along Y axis in a quaternion?
(I can supply the details on how I actually come up with quaternion that represents this partially wrong result, if that is of any help)
Thanks a lot.

May I ask why you are using quaternions? The rotation group works quite well for this kind of problem and is much simpler in application.

-Dan
• Jan 3rd 2008, 01:27 PM
sjcomp
Quote:

Originally Posted by topsquark
May I ask why you are using quaternions? The rotation group works quite well for this kind of problem and is much simpler in application.

I am using quaternions because I'm simulating this situation using 3D graphical engine, which uses quaternions by default (though it can use matrices or Euler rotations as well). Basically I have to change an orientation of an object and given it's facing direction (v1) and the desired facing direction (v2) I can calculate the quaternion that would create a proper change in the orientation. The problem with this approach is that it does not account for the desired Y rotation of my object.
I do not know what rotation groups are (Euler angles?). Could you tell me more about how I can go from having three vectors (initial object direction, surface [to which tape is attached] normal direction, and desired direction of the tape) to three rotational angles, or a rotational matrix, or a quaternion?
Thanks.