Is it correct to use the sum of squared differences (SSD) to determine if two lines are similar?
I have two lines ($L_{1}$ and $L_{2}$):
$A_{1}x+B_{1}y+C_{1} = 0$
and
$A_{2}x+B_{2}y+C_{2}=0$.
I want to know if they're similar to the point that they could be the same line (orientation-wise).
To do this, I'm considering using the Sum of Squared Differences (SSD) as a metric. I would use the parameters ($A,B,C$) of the lines to calculate the SSD. However, I'm not sure if I can use the SSD in this setting.
Is this a correct way to determine if two lines are similar? Should I try a different approach?
Thanks in advance for your help.
$\endgroup$ 21 Answer
$\begingroup$That particular metric is very bad for that particular parameterization. This is because one line can have very different parameters in that system. For example,
$$2x+3y+4=0$$ $$4x+6y+8=0$$
are identical lines but your metric would give a "distance" of
$$(4-2)^2+(6-3)^2+(8-4)^2=29$$
You could avoid this by "normalizing" the equations before applying the metric. One way to do this is to require that $A^2+B^2=1$ and $C\ge 0$. This can be done by replacing $Ax+By+C=0$ with
$$\frac{A\cdot\operatorname{sign}(C)}{\sqrt{A^2+B^2}}+\frac{B\cdot\operatorname{sign}(C)}{\sqrt{A^2+B^2}}+\frac{C\cdot\operatorname{sign}(C)}{\sqrt{A^2+B^2}}=0$$
where $\operatorname{sign}(C)$ is the modified sign function of $C$ such that
$$\operatorname{sign}(C) = \begin{cases} 1, & \text{if $C\ge 0$} \\ -1, & \text{if $C<0$} \end{cases}$$
This replacement can be done since for an actual line, $\sqrt{A^2+B^2}>0$. Then each line has exactly one such equation. You could apply your metric to that equation. You could re-write your metric to combine the normalization with your original metric: I will leave that re-write to you.
I do not claim that this is the best metric, which would depend on some unstated priorities. For example, would two lines that intersect be "closer" or "farther" than two parallel lines, if both cases give the same metric value? Such priorities could adjust the metric.
$\endgroup$