[Math] Get coordinate origin from two points

analytic geometrygeometry

I want to draw a Image onto a Layer.

Where to put this Image I know from two Points A and b:

Point A = Image-Cordinates( 4925, 281) Layer-Coordinates(37325, 49433 )

Point B = Image-Cordinates( 5065, 423) Layer-Coordinates(37329, 61908 )

The image Size is = 5083 × 1563

Basically what I try to calculate is, where the (0,0) coordinate of the Image would be located in the layer? And how this image additionally has to be rotated in order to match the layer-coordinate-points.

I made a drawing to visualize my problem:

enter image description here

So in the IMG there are Point A and B.
The Map-Layer coordinates of this points I also know.

As you can see the purple point (0,0) Coordinate has to be moved. Maybe the image has to be stretched and rotated.

I tried to calculate the layer coordinate by calculating the distance between the points A and B in the image as well as their distance on the layer. But Hence they are not on the same x or y axis I dont know how to calculate the stretching and how to come to the origin point.

Using this example coordinates, how would I get the origin 0,0 point of the image in the layer. So that when I would draw it on the Layer it would match the points?

Thanks

Best Answer

To stretch the image:

  1. calculate the ratio of distances between points A and B in the image and the layer -- it is our scaling coefficient;
  2. set new origin for the image in point A;
  3. rotate axes so that new x axis goes trough point B;
  4. scale x coordinates of the image points with the scaling coefficient from step 1.

After that the image and the layer will have the same scale. From two sets of coordinates of points A and B you can calculate translation and rotation of the image to the layer coordinates.

Related Question