Jump to content
  • Advertisement
Sign in to follow this  
mfawcett

Solve for Rotation/Translation/Scale

This topic is 4473 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'm struggling to come up with a solution to this problem. Perhaps it's better demonstrated than explained. Here is a link to the video: Multi-Touch Gesture video Towards the end, the user rotates and zooms the map using two fingers, but it looks approximated. I want to do something similar. The basic question is, how to keep two OpenGL coordinates "glued" underneath the user's fingers? With just that concept, you can zoom in/out, and rotate. I think it's a very intuitive interface gesture when working with touch sensitive displays. Example: Given input in screen coordinate pairs pair 1 = (50, 50 and 100, 100) - start point pair 2 = (20, 20 and 90, 80) - end point how would you go about solving for a matrix that you can apply to pair 1 to produce pair 2? [Edited by - mfawcett on March 13, 2006 4:22:57 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
wtf? i dont understand what you are saying.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I am assuming that pair 1 is the initial position and pair 2 is the final position.

To keep things simple you should perform all transformations relative to one of the points( i.e 1st finger)

Basically construct 2 vectors, one for each pair of points.

Find the magnitude of the second vector and divide by the magnitude of the first vector. This will be your scaling factor.

v1 = pair1 vector;
v2 = pair2 vector;

scale factor = |v2| / |v1|;

To find the rotation angle just find the angle between the two vectors. Use either cross product or dot product, I forget which one, but its one of those.

To find translation

translation vector = pair2.point1 - pair1.point1;

That should take care of it. Hope that makes sense.


Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I am assuming that pair 1 is the initial position and pair 2 is the final position.

Yes, sorry, I should have been more explicit. Your post makes a lot of sense, thank you. Login next time for a rate++ ;)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!