Given
v = \begin{pmatrix}X \\ Y \\
Z \end{pmatrix}
and a basis
\mathcal B = \left\{
\begin{pmatrix} A \\ B\\ C\end{pmatrix},
\begin{pmatrix} D \\ E\\ F\end{pmatrix},
\begin{pmatrix} G \\ H\\ I\end{pmatrix}
\right\}
.
Calculate the coordinate vector [v]_{\mathcal B} =
\begin{pmatrix} {\color{red}X} \\
{\color{blue}Y} \\ Z \end{pmatrix}
of v
with respect to the basis
\mathcal B
.
\color{red} X
=
kvector.dot([A,B,C],[X,Y,Z])/ kvector.dot([A,B,C],[A,B,C])
\color{blue} Y
=
kvector.dot([D,E,F],[X,Y,Z])/ kvector.dot([D,E,F],[D,E,F])
Z
=
kvector.dot([G,H,I],[X,Y,Z])/ kvector.dot([G,H,I],[G,H,I])
We looking for {\color{red}X}, {\color{blue}Y}
and Z
to form the unique solution of the system of linear equations
\begin{pmatrix}X \\
Y \\
Z \end{pmatrix} =
{\color{red}X} \begin{pmatrix} A \\ B \\ C\end{pmatrix} +
{\color{blue}Y} \begin{pmatrix} D \\ E\\ F\end{pmatrix} +
Z \begin{pmatrix} G \\ H\\ I\end{pmatrix}
.
This can be done either using Gaussian elimination or with the matrix
A=
\begin{pmatrix} A & D & G \\
B & E & H \\
C & F & I\end{pmatrix}
or the Euclidean scalar product (SCP), as the three basis vectors are orthogonal with respect to this SCP - verify this!
To determine {\color{red}X}
we apply the SCP with \begin{pmatrix} A \\ B\\ C\end{pmatrix}
on both sides of the equation and get
\begin{pmatrix} A \\ B\\ C\end{pmatrix} \cdot \begin{pmatrix}X \\
Y \\
Z \end{pmatrix} = kvector.dot([A,B,C],[X,Y,Z]) =
\begin{pmatrix} A \\ B\\ C\end{pmatrix}
\cdot \left(
{\color{red}X} \begin{pmatrix} A \\ B \\ C\end{pmatrix} +
{\color{blue}Y} \begin{pmatrix} D \\ E\\ F\end{pmatrix} +
Z \begin{pmatrix} G \\ H\\ I\end{pmatrix}\right)
.
Due to the bilinearity of the SCP and the orthogonality of the basis, only the right-hand side remains
{\color{red}X} \begin{pmatrix} A \\ B\\ C\end{pmatrix} \cdot
\begin{pmatrix} A \\ B \\ C\end{pmatrix} =
{\color{red}X} \cdot negParens(kvector.dot([A,B,C],[A,B,C]))
.
Thus, together we have:
{\color{red}X} = fractionReduce(kvector.dot([A,B,C],[X,Y,Z]), kvector.dot([A,B,C],[A,B,C]))
.
For the other two coordinates, we then use the respective basis vector.
We get
{\color{blue}Y} = fractionReduce(kvector.dot([D,E,F],[X,Y,Z]), kvector.dot([D,E,F],[D,E,F]))
and
Z = fractionReduce(kvector.dot([G,H,I],[X,Y,Z]), kvector.dot([G,H,I],[G,H,I]))
.