Solve for Rotation/Translation/Scale
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]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement