Global to local coordinates without solving linear equation system I have a given, local coordinate system defined by this equation:
$$
g = a \cdot x + b \cdot y + c \cdot z + o
$$
$x$, $y$ and $z$ are three (perpendicular) unit vectors defining the axis of the local coordinate system (right hand rule).
$o$ is the offset vector. When observing the global coordinate system, the origin of the local system is in $o$.
$a$, $b$ and $c$ are each one component of the local coordinates. This means the local coordinate vector would be $(a,b,c)$.
$g$ is the global coordinates vector corresponding to the local coordinate vector $(a,b,c)$. This makes converting local coordinates to global coordinates very easy. My problem is with converting from global to local coordinates.
You can determine the local coordinates vector $(a,b,c)$ from the global coordinates by solving the following linear equation system (using the Gauss-algorithm or something similar):
$$
g_x = a \cdot x_x + b \cdot y_x + c \cdot z_x + o_x
$$
$$
g_y = a \cdot x_y + b \cdot y_y + c \cdot z_y + o_y
$$
$$
g_z = a \cdot x_z + b \cdot y_z + c \cdot z_z + o_z
$$
The problem I have is that this calculation has to be done multiple times per second on a relatively weak microcontroller. It doesn't have the calculation power to run Gauss each time. Is there any way I can calculate the local coordinates easier than this (for example by calculating a transformation matrix for this coordinate system)?
 A: Consider the matrix
$$ U = \begin{pmatrix} x_x & y_x & z_x \\ x_y & y_y & z_y \\ x_z & y_z & z_z \end{pmatrix}. $$
By your assumption, since $x,y,z$ are of unit length and perpendicular, the matrix $U$ is unitary (so $UU^T = I$). The transformation for local coordinates to global coordinates is given by
$$ \begin{pmatrix} a \\ b \\ c \end{pmatrix} \mapsto  \begin{pmatrix} x_x & y_x & z_x \\ x_y & y_y & z_y \\ x_z & y_z & z_z \end{pmatrix} \begin{pmatrix} a \\ b \\ c \end{pmatrix} + \begin{pmatrix} o_x \\ o_y \\ o_z \end{pmatrix} = \begin{pmatrix} g_x \\ g_y \\ g_z \end{pmatrix}. $$
The inverse transformation is then given by
$$ \begin{pmatrix} g_x \\ g_y \\ g_z \end{pmatrix} \mapsto \begin{pmatrix} x_x & y_x & z_x \\ x_y & y_y & z_y \\ x_z & y_z & z_z \end{pmatrix}^{-1} \begin{pmatrix} g_x - o_x \\ g_y - o_y \\ g_z - o_z \end{pmatrix} = \begin{pmatrix} a \\ b \\ c \end{pmatrix}. $$
But since $U$ is unitary, you know that $U^{-1} = U^T$ so
$$ \begin{pmatrix} a \\ b \\ c \end{pmatrix} = \begin{pmatrix} x_x & x_y & x_z \\ y_x & y_y & y_z \\ z_x & z_y & z_z \end{pmatrix} \begin{pmatrix} g_x - o_x \\ g_y - o_y \\ g_z - o_z \end{pmatrix}. $$
