Re: Distance point <=> straight line in space



James Dow Allen wrote:
On Jul 31, 1:43 am, Daniel Kraft <d...@xxxxxxxx> wrote:
... I need to calculate ... distance[s] ...
... unfortunatelly, my program spents
a large amount of time (~ 95% of total runtime)
in this routine ...

I believe *many* applications for distance
can be rewritten to use distance-squared
(i.e., don't take square roots); for example
if (distance(me, pizzashop) < TWO_MILES)
order(pizzashop, Hold_anchovies);
becomes
if (sqdist(me, pizzashop) < FOUR_SQ_MILES)
order(pizzashop, Hold_anchovies);

Can your application be so rewritten?

Yes, it can; and actually, I already did so, so in fact I save the one square root per iteration in my algorithm; but I thought it would be clearer to state the problem in terms of distance not distance squared :)

Thanks for the suggestion!
Daniel

--
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
.



Relevant Pages

  • Re: Distance point <=> straight line in space
    ... in this routine ... ... I believe *many* applications for distance ... if (sqdist(me, pizzashop) < FOUR_SQ_MILES) ...
    (comp.programming)
  • Re: -- rational distances
    ... This seems to work because you don't have to take square roots, ... anyway require that the frontier of S is only made of rational points, ... required property at all, because you'll have anyway to take square ... roots for the distance from almost all points... ...
    (sci.math)