Distance

Blitz3D Forums/Blitz3D Programming/Distance

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Do not sqr it.
In 2D the distances are small so they don't exceed the float maximum when squared, so you can compare d^2 to it.

the other optimation is NOT to use ^2
Its slower than x*x, the ^x does not make sense with x < 3 performance wise.

->
xdif = x1 - x2
ydif = y1 - y2
d2 = ( xdif*xdif + ydif*ydif)

if d2 < maxDistance * maxDistance then ...