Last active
April 22, 2017 19:29
-
-
Save Artem-Schander/e49be2e1c100deb2dfdd53997999352d to your computer and use it in GitHub Desktop.
Linear equation
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
// f(x) = mx + n | |
// f(y) = (y - n) / m | |
var start = { | |
x: 1, | |
y: 12 | |
} | |
var end = { | |
x: 4, | |
y: 0 | |
} | |
var delta = { | |
x : end.x - start.x, | |
y : end.y - start.y, | |
} | |
var m = delta.y / delta.x | |
var n = - m * start.x + start.y | |
var x = 2 | |
var y = m * x + n | |
console.log(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment