14 Sep
2009
14 Sep
'09
10:19 p.m.
On Mon, 14 Sep 2009, Paul Reiners wrote:
This is a programming question I ran across. Does anyone happen to know the answer?
I am processing a series of points which all have the same Y value, but different X values. I go through the points by incrementing X by one. For example, I might have Y = 50 and X is the integers from -30 to 30. Part of my algorithm involves finding the distance to the origin from each point and then doing further processing.
Here are some very low-tech approaches: If your X and Y domain is small, you could precompute a table of distances. If only your Y domain is small, precompute for x between -ymax^2 and ymax^2 and use distance~=abs(x) beyond that.