Coordinate transformation (or conversion) into yards

334 Views Asked by At

Following is a soccer field with its dimensions.

enter image description here

There is a similar field, but I am capturing coordinates via mouse-movement. So, what (115,75) shows here, is 567.5,369 when I capture the coordinates when the mouse moves. How could I convert a general coordinate (x,y) to (x1,y1) where x1 and y1 are the coordinates in yards.

1

There are 1 best solutions below

0
On

So you want an affine transformation $L\colon\Bbb R^2\to\Bbb R^2$ that maps

  • $\begin{pmatrix} 0\\ 0\end{pmatrix}$ to $\begin{pmatrix} a_0\\ b_0\end{pmatrix}$
  • $\begin{pmatrix} x_1\\ 0\end{pmatrix}$ to $\begin{pmatrix} a_1\\ b_1\end{pmatrix}$ where $x_1\neq 0$ (for you example, take $x_1=115$)
  • $\begin{pmatrix} 0\\ y_2\end{pmatrix}$ to $\begin{pmatrix} a_2\\ b_2\end{pmatrix}$ where $y_2\neq 0$ (for you example, take $y_2=75$)

Since $L$ is supposed to be affine, it can be written in the form $L(x)=Mx+v$ where $$M=\begin{pmatrix}M_{1,1}&M_{1,2}\\ M_{2,1}& M_{2,2}\end{pmatrix}\in\Bbb R^{2\times 2}\qquad \text{ and }\qquad v=\begin{pmatrix} v_1\\ v_2\end{pmatrix}\in\Bbb R^2,$$

So,

  • $\begin{pmatrix} a_0\\ b_0\end{pmatrix}=L\begin{pmatrix} 0\\ 0\end{pmatrix}=v\implies v = \begin{pmatrix} a_0\\ b_0\end{pmatrix}$
  • $\begin{pmatrix} a_1\\ b_1\end{pmatrix}=L\begin{pmatrix} x_1\\ 0\end{pmatrix}=x_1\begin{pmatrix} M_{1,1}\\ M_{2,1}\end{pmatrix}+v\implies \begin{pmatrix} M_{1,1}\\ M_{2,1}\end{pmatrix}=\frac{1}{x_1}\begin{pmatrix} a_1\\ b_1\end{pmatrix}-\frac{1}{x_1}v=\frac{1}{x_1}\begin{pmatrix} a_1-a_0\\ b_1-b_0\end{pmatrix}$
  • $\begin{pmatrix} a_2\\ b_2\end{pmatrix}=L\begin{pmatrix} 0\\ y_2\end{pmatrix}=y_2\begin{pmatrix} M_{1,2}\\ M_{2,2}\end{pmatrix}+v\implies \begin{pmatrix} M_{1,2}\\ M_{2,2}\end{pmatrix}=\frac{1}{y_2}\begin{pmatrix} a_2\\ b_2\end{pmatrix}-\frac{1}{y_2}v=\frac{1}{y_2}\begin{pmatrix} a_2-a_0\\ b_2-b_0\end{pmatrix}$

It follows that $$L\begin{pmatrix}x_1\\ x_2\end{pmatrix}=\begin{pmatrix} \frac{a_1-a_0}{x_1}&\frac{a_2-a_0}{y_2}\\ \frac{b_1-a_0}{x_1}&\frac{b_2-a_0}{y_2}\end{pmatrix}\begin{pmatrix}x_1\\ x_2\end{pmatrix}+\begin{pmatrix}a_0\\ b_0\end{pmatrix}$$ is the transformation you are looking for.