BBS: Inland Empire Archive
Date: 06-22-92 (06:22) Number: 1212
From: RICHARD VANNOY Refer#: NONE
To: ROBERT CHURCH Recvd: NO
Subj: Distance Formula Conf: (2) Quik_Bas
RC>In short, How can I find all of the points between two points on
So the two points are 20, 30, 70, 130
x1 y1 x2 y2
What you're trying to lay out is called the ratio between
the change in x (delta x) and the change in y (delta y).
The ratio is (x2 - x1) / (y2 - y1)
= (70 - 20) / (130 - 30)
= 50 / 100
= 1/2 or .5
in other words for every unit x changes, y changes 2.
(You can do (x1-x2)/(y1-y2) and the minuses and plusses
will work right as long as you are consistant.
So to compute the x,y points between, you do...
ratio = (x2-x1)/(y2-y1)
FOR i = 1 to x2 -x1
x = startx + i
y = INT((starty+i)*ratio+.5)
That will (if I got my math right), will give you the
closest approximate (because you round off y) location of
all the x,y intersections.
Your "i" increment can also be set to just about any value
> MegaMail 2.1b #0:Real programmers use: COPY CON PROGRAM.EXE
--- Maximus 2.00
* Origin: D.J.M.BBS (1:202/307)