Sign in to follow this  
mfawcett

Solve for Rotation/Translation/Scale

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
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

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