No.13307947 ViewReplyOriginalReport
Need help figuring out an algorithm to determining a point's location on a scaled map.

I'm making an interactive map for a game, where various points of interest can be added to or removed from the map. This part has already been done. The next objective is to allow myself to click on the on any of those POIs, and it would put an X over it indicating that the POI has been complete. My map can be zoomed and panned, so I'm working with 3 offsets and a zoom factor. Below is an example of the information available to me.

Rectangle for icon -- X: 4825, Y: 2791, W: 40, H: 40

I clicked as close to center of that icon as my eyeball can determine and this is the information I get:
Canvas click location: 429, 257
Moving Point: -2480, -673 (panning -- this is the top-left point of the image's relation to the top-left of the canvas's top-left)
Crop rectangle X/Y: 1942, 1892 (the original image is 8192x8192, but nearly 2k pixels on each side is unneeded.. to get back to the original locations for the icons I must return to the original image's size)

Scale: 1.0178071

When I programmatically set the scale to 1.0, I can get the value by adding the three offsets above (ie: for X I would 429+1942+-2480*-1). However, when the zoom is applied I can not figure out how to use the scale factor to get the original icon locations. The above offsets manipulated by the zoom should give you a location somewhere with an X between 4825 and 4865, and a Y between 2791 and 2831.

More examples; all share the icon's rectangle and croprect:
MP: -2557, -767
CL: 564, 253
Scale: 1.6178073

MP: 18, 18
CL: 635, 205
Scale: .21780702

MP: -1898, -744
CL: 926, -744
Scale: .9178071