This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
The best way to relate my question is by scenario:
You have an application that draws an image on a screen. Let's say that image is just a big box. You select the point directly on the top left corner of the box. Let's say that point ON THE SCREEN is 100, 100 to make it easy. The user then moves that image to the right and zooms it. No rotation was involved. He then selects the same spot on the box...very top left. Of course since the box moved the screen coordinates are no longer 100, 100. Let's say they are now 120, 90.
How can you translate the 120, 90 back to what it would have been (100, 100) if the user had not panned and zoomed the image?
The code to move the image after the user pans and zooms looks like this. Note that the mState object also holds the X/Y coordinate the user touched on.
What is the formula that needs to be applied to that point to get it back to what it would have been pre-translation and scale in this code?