Reconstructing vectors from inner products

Let $v_i = [a_{i1},a_{i2},a_{i3}]^T$. As we know $v_3$, we have 6 unknowns thus we need 6 equations.

Since you have all inner product, we have \begin{equation} \begin{bmatrix} v_1^T & v_2^T & v_3^T \end{bmatrix} \begin{bmatrix} v_1 & v_2 & v_3 \end{bmatrix} = \begin{bmatrix} v_1^Tv_1 & v_1^Tv_2 & v_1^Tv_3 \\ v_2^Tv_1 & v_2^Tv_2 & v_2^Tv_3 \\ v_3^Tv_1 & v_3^Tv_2 & v_3^Tv_3 \end{bmatrix} \end{equation} and the right hand side is known.

Since you know $v_3$, we obtain following 5 equations which involves 6 unknowns. Note that $v_3^Tv_3$ does not give any information.

Thus we have 6 unknowns and 5 equations.

For example. let $v_3 = [0, 0, 1]^T$, $v_1=[1,0,0]^T$ and $v_2=[0,1,0]^T$. Even though we know all inner products, $v_1' = [\sin \theta, \cos \theta, 0]^T$ and $v_2' = [\cos \theta, -\sin \theta, 0]^T$ will satisfy the inner product conditions.


Let \begin{align} v_1&=x_1e_1+x_2e_2+x_3e_3\\ v_2&=y_1e_1+y_2e_2+y_3e_3\\ v_3&=ae_1+be_2+ce_3 \end{align} and $\langle v_1,v_2\rangle=A$, $\langle v_1,v_3\rangle=B$, $\langle v_2,v_3\rangle=C$, $\langle v_1,v_1\rangle=P$, $\langle v_2,v_2\rangle=Q$. The conditions give a nonlinear system $$ \begin{cases} x_1y_1+x_2y_2+x_3y_3=A \\ x_1^2+x_2^2+x_3^2=P \\ y_1^2+y_2^2+y_3^2=Q \\ ax_1+bx_2+cx_3=B\\ ay_1+by_2+cy_3=C \end{cases} $$ of five equations in six unknowns. If the system is solvable, it will generally have infinitely many solutions.

You can first solve the last equation (parametrically). Then the first and fourth equations become a linear system. Finally, you have to normalize the solutions to satisfy the conditions on the norms.


Assuming the vectors are in general position, i.e. no two are parallel:

Select an arbitrary unit vector $t$ perpendicular to $v_3$ (the usual trick for doing so robustly is to take $t = (e\times v_3)/\|e\times v_3\|$, where $e$ is the vector with a 1 in the entry corresponding to the least-magnitude entry of $v_3$, and a 0 elsewhere.)

We can assume $$v_1 = \alpha_1 t + \beta_1 v_3$$ $$v_2 = \alpha_2 t + \beta_2 v_3 + \gamma_2 t\times v_3$$

Now $$\beta_1 = v_1\cdot v_3 / \|v_3\|^2$$ $$\alpha_1 = \sqrt{\|v_1\|^2 -\beta_1^2\|v_3\|^2}$$ $$\beta_2 = v_2\cdot v_3 / \|v_3\|^2$$ $$\alpha_2 = \frac{v_1\cdot v_2 - \beta_1 v_2\cdot v_3}{\alpha_1}$$ $$\gamma_2 = \pm \sqrt{\frac{\|v_2\|^2 -\alpha_2^2 - \beta_2^2\|v_3\|^2}{\|v_3\|^2}}.$$

The answer is of course only unique up to (1) selection of $t$ and (2) selection of the sign of $\gamma_2$, i.e. the handedness of the resulting $(v_1,v_2,v_3)$ coordinate frame. There are two smooth families of solutions.