How to calculate the opposite type of rotation of a quaternion?

I have a quaternion rotation, as usually described by 4 values: abcd . Let's say it transforms the x axis, so I'm looking at some object in front. Now I want to change this rotation, so I look at the object from the back. So I want to change the viewpoint from front to back, but do it with this rotation.

How can I calculate the opposite rotation?

+4
source share
2 answers

Studying the wikipedia page, it seems that if you want to rotate 180 Β° around z , then the corresponding rotation of Quaternion will be simple:

 0 0 0 1 

The key here is the formula enter image description here , where (w, x, y, z) = (a, b, c, d).

Indeed, since cos (90 Β°) = 0 and sin (90 Β°) = 1, replacing alpha by 180 Β° and u by (0, 0, 1) gives you (0, 0, 0, 1).

Change As the Christian noted, the upward direction should not be z , but can be any unit vector u = (x, y, z) (otherwise we normalize it by dividing by its norm). In this case, the corresponding 180 Β° rotation will be

 0 xyz 

Now, to apply this rotation to move around the object, say that you have the position wind direction of your camera's c_pos and c_dir , then simply (left) matches it with q = (0 xyz) and move the camera position accordingly. Sort of

 c_dir = q * c_dir * q^-1 c_pos = 2 * o_pos - c_pos 

where o_pos is the position of the object, and c_dir should be converted to a quaternion with the real part 0.

+2
source

In my case, hel me this ..

original quat (xyzw) opposite oriented quat (y -xw -z)

-2
source

All Articles