Sign in to follow this  

from world space to object space with quaternions

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

I have to objects with position(x,y,z) and orientation(a quaternion)and now i want to get the position of object 2 in objectspace of object 1. Some time ago i already made it with matrices, but i don't know what to do with quaternions. Berion

Share this post


Link to post
Share on other sites
The location of a point local to object 1 in world space is: P = T1Q1P1Q1-1. Thus, P1 = Q1-1T1-1PQ1
Since the location of a point local to object 2 in world space is: P = T2Q2P2Q2-1, the location of a point local to object 2 in object 1's space is: P1 = Q1-1T1-1T2Q2P2Q2-1Q1.

The multiplications above are a mix of matrix and quaternion multiplications. I'll leave it to you to sort it out. Also, I might have Q-1 and Q reversed, I can never remember.

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnBolton
The location of a point local to object 1 in world space is: P = T1Q1P1Q1-1. Thus, P1 = Q1-1T1-1PQ1
Since the location of a point local to object 2 in world space is: P = T2Q2P2Q2-1, the location of a point local to object 2 in object 1's space is: P1 = Q1-1T1-1T2Q2P2Q2-1Q1.

I might have Q-1 and Q reversed, I can never remember.

wow.... you're being serious aren't you?

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
Quote:
Original post by JohnBolton
The location of a point local to object 1 in world space is: P = T1Q1P1Q1-1. Thus, P1 = Q1-1T1-1PQ1
Since the location of a point local to object 2 in world space is: P = T2Q2P2Q2-1, the location of a point local to object 2 in object 1's space is: P1 = Q1-1T1-1T2Q2P2Q2-1Q1.

I might have Q-1 and Q reversed, I can never remember.

wow.... you're being serious aren't you?

Come on. The math might look complicated but it is trivial.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well if you are like me, you will try to simplify the process.
This is what I would do:
A point common to both bodies can be expressed as:

p = pl1 * R1 + T1
p = Pl2 * R2 + T2

Since it is the same point

pl1 * R1 + T1 = Pl2 * R2 + T2

now determine pl1 you get:

pl1 = (Pl2 * R2 + T2 – T1) * R1’

let T2 – T2 = T

pl1 = Pl2 * R2 * R1’ + T * R1’

Now in quaternion form

Q = Q2 * Q1’ (the product of quaternion Q2 and the conjugate of Q1)
T = (T2 – T1) * Q1’ (the product of the different of offset time the conjugate of Q1)

Share this post


Link to post
Share on other sites
thanks for the help, but i found out that my quaternion code worked. I didn't changed anything and it suddenly worked. The error was somewhere else, but I don't know where.

Share this post


Link to post
Share on other sites

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