# Isolate scalar in matrix equation

I have the equation: $$p_2 \approx K (dR+tn^T) K^{-1} p_1$$

where $p1$, $p2$ are $3x1$ homogeneous column vectors, t and n are $3\times1$ column vectors, $K$ and $R$ are $3\times 3$ matrices, $R$ is a rotation matrix, and $d$ is a scalar. The $\approx$ means equal up to a scalar factor.

I want to isolate the scalar $d$ in terms of the others. I've only been able to find a way assuming it is an equality (not an up to scale equality), but it doesn't give the correct $d$. I test this by putting the obtained $d$ in the original equation with some real data and dehomogenising (divide both sides of the equation by the 3rd row). How could I isolate the d in terms of the others? This is my attempt:

$$p_2 = d K R K^{-1} p_1 + Ktn^TK^{-1}p_1$$ $$(KRK^{-1})^{-1}(p_2-Ktn^TK^{-1}p_1)=d I p_1$$ $$\frac{p_1^T}{p_1^Tp_1}(KR^TK^{-1})(p_2-Ktn^TK^{-1}p_1)=d$$

First we want to turn the up-to scale equality $\approx$ into an actual equality.

We do that by introduction an additional variable, the scale factor/scalar $s$. The equation becomes:

$s*p2 = K (dR+tn^T) K^{-1} p1$ .

Multiply to the left by $K^{-1}$. Also, denote $p_{k2} = K^{-1}p2$ and $\hspace{0.25mm}$ $p_{k1} = K^{-1}p1$ .

The equation to solve becomes:

$s*p_{k2}=(dR+tn^T)p_{k1}$, with $s$ and $d$ unknowns.

Expanding and grouping the terms, we get:

$s*p_{k2}-d*Rp_{k1}=<n,p_{k1}>*t$

We have to decompose $<n,p_{k1}>*t$ as a linear combination of $p_{k2}$ and $Rp_{k1}$.

Since we are in a 3d space, the equation might not always have a solution,as it gives 3 equations with 2 unknowns (overdetermined). Assume it does have a solution.

Multiply to the left by $p_{k2}^T$, and $(Rp_{k1})^T$ to get two equations:

$s*<p_{k2},p_{k2}>-d*p_{k2}^TRp_{k1}=<n,p_{k1}><{p_{k2}},t>$

$s*p_{k2}^TRp_{k1}-d*<p_{k1},p_{k1}>=<n,p_{k1}><{p_{k1}},t>$

From this we get:

$$d=<n,p_{k1}>\frac{<{p_{k2}},t>p_{k2}^TRp_{k1}-<{p_{k1}},t><p_{k2},p_{k2}>}{<p_{k1},p_{k1}><p_{k2},p_{k2}>-(p_{k2}^TRp_{k1})^2}$$

This is a homogenous equation, both in $p_{k1}$ and $p_{k2}$.

Now, substitute $K^{-1}p2=p_{k2}$ and $K^{-1}p1=p_{k1}$, to obtain $d$ in terms of the original variables.

• Thanks! the d calculated with your expression is the correct one for the data I use. Although following your derivation I get stuck on the second equation when you multiply by $(Rpk1)^T$, I can't get the same equation you have written. Would you mind elaborating on this step? Sep 7, 2017 at 10:38
• I couldn't get the comments to format the way I want so I elaborated here . Sep 7, 2017 at 15:10
• Thanks! the rule I wasn't applying is the $a^T=a$ which seems obvious but I wasn't thinking about it. Still, I can't see how the $R^T$ disappears on the rhs of the 2nd equation Sep 7, 2017 at 16:30
• That's a general property of rotation matrix. It preserves norms and angles. So we have $<v_1,v_2> = <Rv_1,Rv_2>$, for all $v_1,v_2$ . This means $v_1^TR^TRv_2=v_1^Tv_2$, so $R^TR = I$ in general. Sep 7, 2017 at 18:36
• Ok, thanks! I see how it works now. Sep 8, 2017 at 11:32