Keep It Simple, Stupid | |
PerlMonks |
Re: Plotting A Lineby flounder99 (Friar) |
on Oct 27, 2003 at 22:58 UTC ( [id://302560]=note: print w/replies, xml ) | Need Help?? |
From algebra I: Equation of a line: y = mx + b what you know:
x1,y1
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
In Section
Seekers of Perl Wisdom
|
|