in reply to Plotting A Line
Equation of a line:
y = mx + b
what you know:
x1,y1
x2,y2
Therefore:
y1 = mx1 + b
y2 = mx2 + b
Subtracting:
y1 - y2 = m(x1 - x2)
if x1 == x2 then it is a vertical line on y
therefore (assuming x1 != x2)
m = (y1 - y2)/(x1 - x2)
substituting in first equation:
y1 = (y1 - y2)/(x1 - x2)x1 + b
b = y1 - (y1 - y2)/(x1 - x2)x1
therefore the equation of a line (assuming x1 != x2) is:
y = (y1 - y2)/(x1 - x2)x + (y1 + y1 - y2)/(x1 - x2)x1
--
flounder
|
---|