Solve for Rotation/Translation/Scale

Started by
3 comments, last by sonyafterdark 18 years, 1 month ago
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]
--Michael Fawcett
Advertisement
wtf? i dont understand what you are saying.
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.


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++ ;)
--Michael Fawcett
Amasing. Absolutely astounding. Out of a sci-fi movie 4 sure.

This topic is closed to new replies.

Advertisement