BBS: Inland Empire Archive
Date: 06-24-92 (19:51) Number: 1339
From: JEAN CREPEAU Refer#: NONE
To: ROBERT CHURCH Recvd: NO
Subj: Distance Formula Conf: (2) Quik_Bas
In a message to ALL, ROBERT CHURCH wrote:
RC=> I need some help with a little math. For a game I'm writing, I need
to not only find the distance between two points on a grid, but to find
the POINTS on the grid.
RC=> In short, How can I find all of the points between two points on
To calculate the distance between two points, it's easy...
where (x1,y1) is your first point
(x2,y2) is the second point
d is the distance (in point units)
To find all the points between two points, you should use a line-
if dx=0 and dy=0 then
if abs(dy)>abs(dx) then mx=dx/dy:my=1 else mx=1:my=dy/dx
loop until x=x2 and y=y2
This is not an optimized program nor has it been tested. It's only
to show you the algorithme. In your case, PSET should be replaced by what
you want to do.
* Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)