Projecting coordinates on to X,Y grid

54 Views Asked by At

I have some coordinates, [x,y] top left corner, and [x,y] bottom right corner, I want to calculate these in relation to a grid which is 600 * 585

So. -8200,8150 = 0,0 on the grid, and 8239,-7639 = 600, 585

How do I find e.g. position 1500,600 inside this grid?

1

There are 1 best solutions below

0
On BEST ANSWER

Assuming a linear relationship, we want to find constants $a,b,c,d$ such that: \begin{align*} a(-8200) + b &= 0 \\ a(8239) + b &= 600 \\ c(8150) + d &= 0 \\ c(-7639) + d &= 585 \\ \end{align*} Solving, we find that: \begin{align*} a &= \frac{600}{16439} \\ b &= \frac{4920000}{16439}\\ c &= \frac{-195}{5263} \\ d &= \frac{1589250}{5263} \\ \end{align*} So given any coordinate $[x,y]$, we can transform it to the position on the grid given by: $$ \left(\frac{600x + 4920000}{16439}, \frac{-195y + 1589250}{5263}\right) $$ For example, $[1500, 600]$ would get mapped to the position: $$ \left(\frac{5820000}{16439}, \frac{1472250}{5263}\right) \approx (354.0361, 279.7359) $$