Can you please help me to figure out a way to obtain global coordinates of a point which is defined within local coordinates system.
Known:
(x,y) origin of the local coordinate system.
angle of the local coordinates system relative to global coordinate system.
(x,y) coordinate of the point with in local coordinate system.
Looking for:
(x,y) coordinate of the point with in global coordinate system.
Thank you so much!
Oleg
Best Answer
Take $x,y$ the global coordinates, $x^\prime,y^\prime$ the local coordinates, $(h,k)$ the global coordinates of the local system's origin, and $\varphi$ the anticlockwise angle from the global system's horizontal ($x$) to the local system's "horizontal" ($x^\prime$).
What is needed, then, to convert from $(x^\prime,y^\prime)$ to $(x,y)$ is to 1. shift the origin; and 2. rotate by $\varphi$ clockwise. This sequence is most easily expressed in matrix-vector notation:
$$\begin{pmatrix}x\\y\end{pmatrix}=\begin{pmatrix}\cos\,\varphi&\sin\,\varphi\\-\sin\,\varphi&\cos\,\varphi\end{pmatrix}\cdot\left(\begin{pmatrix}x^\prime\\y^\prime\end{pmatrix}-\begin{pmatrix}h\\k\end{pmatrix}\right)$$
or explicitly,
$$\begin{align*}x&=(x^\prime-h)\cos\,\varphi+(y^\prime-k)\sin\,\varphi\\y&=-(x^\prime-h)\sin\,\varphi+(y^\prime-k)\cos\,\varphi\end{align*}$$