Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Plotting A Line

by flounder99 (Friar)
on Oct 27, 2003 at 22:58 UTC ( [id://302560]=note: print w/replies, xml ) Need Help??


in reply to Plotting A Line

From algebra I:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://302560]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found