Sign in to follow this  

quick 2d transformation question

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

e.g. I have two unit cubes A and B, A is centered at the origin, B is centered at (1, 0), both have a rotation of 0. I want to be able attach A to B, rotate B 180 degrees, then break the two cubes apart and at the end have a world transformation for A that moves it to (2, 0) with a rotation of 180 degrees. How do I do this in a generic way? My thinking is: 1. Move A into the local space of B and store that transformation C 2. Do whatever transforms to B (this step may occur over many many frames) 3. Multiply transform B by the inverse of C to be the new world transform of A? Or is it the other way around? Step 3 is the bit I'm struggling with. Any help would be great, thanks, s [Edited by - Thergothon on September 20, 2008 2:53:16 AM]

Share this post


Link to post
Share on other sites
Normally a local space is given by the transformation that relates the local space to its superior space, e.g. the global space. Hence applying that transformation in the forward manner means to re-relate an entity of the local space to the (in this example) global space. Applying the inverse transformation re-relates it to the local space (if it was given in the global one before, of course).

BTW: In the following I use column vectors; you have to revert the multiplication orders if you use row vectors.

If GA and GB are the co-ordinate frames of A and B, resp., in the global space, then
GB-1 * GA
relates A to the local space of B. Then you apply the "whatever transforms to B" in step 2:
M * GB-1 * GA
Then you "detach" A from B by applying the B's local-to-global transform:
GB * M * GB-1 * GA

The above formula show a typical structure, namely a wrapping around the origingal transformation,
GB * M * GB-1
where the wrapping does a correction of the reference system (the inverse term on the right) and later "undoes" the correction (the term on the left).

Of course, herein M is defined to work in the local space of B. I infered this from the OP. If it isn't correct, then you have to chose another space as reference, and do analogous stuff as those above.

Share this post


Link to post
Share on other sites
That all makes sense, I just don't understand how that gives you the final local->global transformation for A. Numbers always help...

Say we have two polygons with the following xforms to move them from local->global space:

xformA = positionA, orientationA
xformB = positionB, orientationB

So transform A into Bs local space:

xformC.positionC = (positionA - positionB)*orientationBT
xformC.orientationC = orientationA*orientationBT

...apply transforms to B over time so xformB is different than the above...

Now i want to detach A and be left with a xformA allowing me to transform A to its new world space, how do i calculate xformA given I only know xformC and the new values for xformB?

Thanks heaps for your help, I appreciate it :)

s.

Share this post


Link to post
Share on other sites
From your previous post I conclude that you're using row vectors. Then the above formula has to be reverted to meet your convention:
GA * GB-1 * M * GB

Comparing your approach with this formula shows that your C is
C := GA * GB-1
and that the remaining
M * GB =: GB'
denotes the modified B (accordingly to point 2. in the OP). Hence, multiplying anything that is given w.r.t. the space B by GB' does both modifying it and transforming it back to global space.

Share this post


Link to post
Share on other sites
All the stuff you have posted makes perfect sense and is exactly how I was looking at the problem. My confusion stemmed from the fact that I am an idiot and was applying the final B' transformation to points in A that had been transformed into the global space to test whether my A->B function was working correctly. Applying the transform: C * GB', to the local points in A is what I should have been doing, and it does in fact work.

Thanks for your patience.

Share this post


Link to post
Share on other sites

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