Skip to content

Instantly share code, notes, and snippets.

@Artem-Schander
Last active April 22, 2017 19:29
Show Gist options
  • Save Artem-Schander/e49be2e1c100deb2dfdd53997999352d to your computer and use it in GitHub Desktop.
Save Artem-Schander/e49be2e1c100deb2dfdd53997999352d to your computer and use it in GitHub Desktop.
Linear equation
// 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