[Tutor] Fastest (x,y) distance calculation

Zak Arntson zak at harlekin-maus.com
Fri Sep 12 16:01:42 EDT 2003


> [Raymond Hettinger]
>> > Distance calculations are much cheaper if you store the coordinates
>> > as complex numbers and use abs().

I don't know the concept behind using complex numbers and abs to determine
distance. How does that work?

> Executive summary:   abs(z1-z2)  beats  the (deltax**2 + deltay**2)
> approach

(deltax * deltax) + (deltay * deltay) beats the **2 approach, but only
decreases ~0.8 times when I tried it.

I'm also considering creating some sort of data structure that aids in
nearest-point calculating. Any suggestions?

--
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em



More information about the Tutor mailing list