Distance Formula

 BBS: Inland Empire Archive
Date: 06-21-92 (02:32)             Number: 970
From: PAUL LEONARD                 Refer#: NONE
  To: ROBERT CHURCH                 Recvd: NO  
Subj: Distance Formula               Conf: (2) Quik_Bas
On or about <Jun 20 09:31>, Robert Church (1:105/319.27) scribbled:

 RC>    In short, How can I find all of the points between two points on
 RC>    a grid?

Given two points (x1,y1) and (x2,y2), you can derive the
equation of the line they define using y = mx + b.  Slope
m = (y2 - y1) / (x2 - x1) and b is found by substituting
into the slope formula a known point and the point whose x
co-ordinate is 0, then solving for the unknown y.

All the points that you're looking for satisfy the equation
of the line and meet the condition x1 <= x <= x2 (as well
as y1 <= y <= y2).

An easy example...
Points (1,1) and (2,2) give a slope of m=(2-1)/2-1)=1.
1=(y-1)/(0-1), so b=0 and the equation of the line is y=1x+0 or y=x.
So all points such that x=y and 1<=x<=2 will satisfy your conditions.


--- msged 2.07
 * Origin: PTL Pointwork (1:105/48.111)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET