Re: Distance point <=> straight line in space
- From: Daniel Kraft <d@xxxxxxxx>
- Date: Thu, 31 Jul 2008 12:04:46 +0200
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
.
- References:
- Distance point <=> straight line in space
- From: Daniel Kraft
- Re: Distance point <=> straight line in space
- From: James Dow Allen
- Distance point <=> straight line in space
- Prev by Date: Re: Distance point <=> straight line in space
- Next by Date: Re: Distance point <=> straight line in space
- Previous by thread: Re: Distance point <=> straight line in space
- Next by thread: Re: Distance point <=> straight line in space
- Index(es):
Relevant Pages
|