Re: Distance point <=> straight line in space



Ben Bacarisse wrote:
V = (p2 - p1)/norm_squared(p2 - p1);
According to the formula on MathWorld and to my tests, this should in
fact be a normalized vector, so not norm_squared here.

Do check again... I am highly fallible in such matters, but I've gone
back and can't see it myself. My suggestion is formula (6) from that
page and everything there is either a vector difference or involves
|...|^2. I divided out by |x2-x1|^2 and I can't see any actual
normalisation.

Their formula (6) is:

d^2 = (|x1 - x0|^2 * |x2 - x1|^2 - ((x1 - x0) * (x2 - x1))^2) /
|x2 - x1| ^2
= |x1 - x0|^2 - ((x1 - x0) * (x2 - x1))^2 / |x2 - x1|^2
= |x1 - x0|^2 - ((x1 - x0) * (x2 - x1) / |x2 - x1|)^2
= norm_square (Q) - (Q * V)^2, where V = (x2 - x1) / |x2 - x1|, single normalization.

Cheers,
Daniel

Thanks for this suggestion, it works and gives around 20% speed-up,
quite nice :)

Excellent. 20% is what one would expect from saving 20% of the
operations, but it is good when practise follows theory.



--
Done: Arc-Bar-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
Underway: Cav-Dwa-Law-Fem
To go: Cav-Hea-Kni-Mon-Pri-Ran-Rog-Tou
.