Skip to content

Instantly share code, notes, and snippets.

@bradparker
Created December 31, 2014 03:33
Show Gist options
  • Save bradparker/d52ce56364ada0ada4b6 to your computer and use it in GitHub Desktop.
Save bradparker/d52ce56364ada0ada4b6 to your computer and use it in GitHub Desktop.
Line, slope intercept form
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