Sign in to follow this  

how to compute this quaternion

This topic is 4247 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
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

This topic is 4247 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this