Jump to content
  • Advertisement
Sign in to follow this  
shaobohou

how to compute this quaternion

This topic is 4579 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

given two quaternions P and Q representing orientations, i would like to compute a quaternion D such that: D * P = Q However I would like the axis of rotation of D to be fixed (for my purpose the desired axis of rotation is the y axis), so the problem is one of minimising the difference between D*P and Q. I feel there should be a close form solution but my calculus is not that good. any help will be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Think of this in terms of unit-length vectors. Let Q*Inverse(P) = w + x*i + y*j + z*k, where (w,x,y,z) is a known unit-length vector. Let D = cos(t/2) + sin(t/2) * (u0*i + u1*j + u2*k), where (u0,u1,u2) is a unit-length vector that you require to be constant. The variable is the angle of rotation t. D is a unit-length vector (cos(t/2),u0*sin(t/2),u1*sin(t/2),u2*sin(t/2)).

As 4-tuples, you want to choose t so that D is a close to Q*Inverse(P) as possible on the 4D unit hypersphere. Do this by choosing t to maximize the dot product of D and Q*Inverse(P), which minimizes the angle between the two vectors. The dot product is F(t) = w*cos(t/2) + p*sin(t/2), where p = u0*x + u1*y + u2*z. Take the derivative, F'(t) = -w*sin(t/2)/2 + p*cos(t/2)/2, and set it equal to zero. The solution is (cos(t/2),sin(t/2)) = (w,p)/sqrt(w*w+p*p). Another solution is the negative of this but it produces the minimum, not the maximum. The maximum value of F is sqrt(w*w+p*p). In a numerical implementation, you can use t = 2*atan2(p,w).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!