Determining the Angle Between a Local Coordinate Frame and a Superordinate Frame

262 Views Asked by At

I have two 2D coordinate frames, one local and one regional. I have five points measured on both systems and I want to figure out the translation and rotation parameters between these two systems.

Two coordinate systems one local and one regional, both on a 2D plane enter image description here

Picture above for reference, I know how to determine the translation parameters $tx$ and $ty$, but when I try to find the angle $a$ utilizing the inverse tangent I end up with many different answers for each set of x,y coordinates.

1

There are 1 best solutions below

0
On BEST ANSWER

The relation between the two frames is

$ p = t + R q $

where $p$ is the coordinate vector in the regional frame (red), and $q$ is the coordinate vector in the local frame (green). $t = (t_x, t_y) $ is the offset of the local frame with respect to the regional frame, and $R$ is a rotation matrix.

Now, suppose you have two pairs $p_1, q_1$, and $ p_2, q_2 $, then

$ p_1 = t + R q_1 $

$ p_2 = t + R q_2 $

Therefore,

$ p_1 - p_2 = R (q_1 - q_2)$

Let $u = p_1 - p_2 = (u_x, u_y)$ and $v = q_1 - q_2 = (v_x, v_y) $

Then

$u_x = \cos(\alpha) v_x - \sin(\alpha) v_y $

$u_y = \sin(\alpha) v_x + \cos(\alpha) v_y $

Therefore,

$ u = A [\cos(\alpha) , \sin(\alpha) ] ^T$

where

$ A = \begin{bmatrix} v_x && - v_y \\ v_y && v_x \end{bmatrix} $

Therefore, it follows that

$\begin{bmatrix} \cos(\alpha) \\ \sin(\alpha) \end{bmatrix} = A^{-1} u $

Now that we have $\cos(\alpha)$ and $\sin(\alpha)$, we have $R$ given by

$ R = \begin{bmatrix} \cos(\alpha) && -\sin(\alpha) \\ \sin(\alpha) && \cos(\alpha) \end{bmatrix} $

And we have the angle $\alpha = \text{Atan2}(\cos(\alpha), \sin(\alpha)) $

Having found $R$, we go back to the first equation

$p_1 = t + R q_1 $

Now we can solve for the offset vector $t$

$ t = p_1 - R q_1 $