[futurebasic] An entertaining problem solved

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2000 : Group Archive : Group : All Groups

From: Phil Yates <phil.yates@...>
Date: Wed, 02 Feb 2000 10:16:43 +0000
May I thank all those who responded, and in particular both Jay Reeve and
Robert Purves, who both came up with excellent working solutions. Of the
two, I'll probably use Robert's - but that's for other reasons not explained
in the original post.

One thing is a good example of how we all get into habits. For years, to get
distances between points on the screen, I'd been using :

LOCAL FN GetRange(X1,Y1,X2,Y2)
  Xdiff = ABS(X1 - X2)
  Ydiff = ABS(Y1 - Y2)
  Dist = SQR((Xdiff * Xdiff) + (Ydiff * Ydiff))
END FN = Dist

But Jay suggested :

LOCAL FN GetRange(X1,Y1,X2,Y2)
  Xdiff = (X1 - X2)
  Ydiff = (Y1 - Y2)
END FN = USR _sqRoot((Xdiff * Xdiff) + (Ydiff * Ydiff))

which is dramatically faster.

I don't consider myself a good programmer; but when I stand on other
people's shoulders I can see forever.

Thanks Again,