开发者

How to compute opposite view from a quaternion rotation?

I have a quaternion rotation, as usually described by 4 values: a b c d. Lets say it transforms the x axis so that i look at some object from the front. Now i want to change this rotation so i look at the object from the back. So basicly i want to change the viewpoint from front to back, but do that using this rotation.

How can the oppos开发者_Python百科ite rotation be computed?


Learning from the wikipedia page, it seems that if you want to perform a 180° rotation around the z axis, then the corresponding Quaternion rotation would simply be:

0 0 0 1

The key here is the formula

How to compute opposite view from a quaternion rotation?

, where (w,x,y,z) = (a,b,c,d).

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

Edit: As Christian has pointed out, the up direction need not be z, but may be any unit vector u = (x,y,z) (otherwise normalize it by dividing by its norm). In that case, the corresponding 180° quaterion rotation would be

0 x y z

Now to apply this rotation in order to move around the object, say you have the position an the direction vetors of your camera c_pos and c_dir, then simply (left) conjugate it by q = (0 x y z), and move the camera position accordingly. Something like

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 0 real part.


In my case, hel me this..

original quat (x y z w) opposite oriented quat (y -x w -z)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜