Created
December 31, 2014 03:33
-
-
Save bradparker/d52ce56364ada0ada4b6 to your computer and use it in GitHub Desktop.
Line, slope intercept form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Line (slope, intercept) { | |
this.slope = slope | |
this.intercept = intercept | |
} | |
function getX (y) { | |
y = y || 0 | |
return (y - this.intercept) / this.slope | |
} | |
Line.prototype.getX = getX; | |
function getY (x) { | |
x = x || 0 | |
return this.slope * x + this.intercept | |
} | |
Line.prototype.getY = getY; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment