# Reverse coordinate mapping of object or a point

Mapping Problem diagram/description

The screen size and coordinates (a,b,c,d) are known, and the Area of Interest (AOI) size and coordinates (x,y,w,z) are known.

If an object/coordinate/pixel, xx(1,1) is detected in AOI, how do I find or map the coordinates to xx(2,3)?

Note The AOI size/coordinates, and the location of the object/coordinate/pixel/point, even if changed, should result in the correct mapping of the detected object on the screen.

If the units are the same in both axis systems, the transformation equations is just that of a translation

$$(x_s,y_s)=(x_a,y_a)+(1,2)$$ (where $$(1,2)$$ are the coordinates of the top-left corner of the AOI wrt the screen).

Reciprocally,

$$(x_a,y_a)=(x_s,y_s)-(1,2).$$

Combine a polar coordinate system with the line slope formula and the line distance formula.

Or use a land surveying system:

Any y-coordinate that is South of zero is negative. Any x-coordinate that is West of zero is negative.

Point A is (y1, x1) . Point B is (y2, x2) .

The direction of A to B is:

InvTan((x2 - x1)/(y2 - y1)) .

If (x2 - x1) is positive that is East else West. If (y2 - y1) is positive that is North else South. This procedure allows a quadrant direction to be determined between any two points.

The distance of A to B is:

SquareRoot of ((x2 - x1)^2 + (y2 - y1)^2) .

The combination of direction and distance is a vector but here as an inverse. The coordinates of a point is the location of the point.

Forwarding a point (or setting a point) from A to B is:

y2 = y1 + (Cos(Direction) * Distance) . x2 = x1 + (Sin(Direction) * Distance) .

A North direction is a positive value added to y1 else negative. An East direction is a positive value added to x1 else negative.

• There is absolutely no reason to use polar coordinates. This adds tons of confusion and complexity.
– user65203
Commented Dec 2, 2018 at 14:45

If the area-of-interest is a picture-in-picture feature then it is both scaled and translated.

Scaling multiplies all coordinates and both x and y coordinates by the same scalar. Scaling just makes the figure bigger or smaller but proportionally the same.

Translating adds the same x translation value to all x coordinates and adds the same y translation value to all y coordinates. Translating just moves the figure without changing its size.

Then the inverse operations are obvious.