Advertisement
ShadowEmbrace

Vector-Math

Feb 17th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function () {
  2.     return {
  3.         'add': (x, y) => { return [x[0] + y[0], x[1] + y[1]] },
  4.         'multiply': (x, scalar) => { return [x[0] * scalar, x[1] * scalar] },
  5.         'length': (x) => { return Math.sqrt(x[0] ** 2 + x[1] ** 2) },
  6.         'dot': (x, y) => { return (x[0] * y[0]) + (x[1] * y[1]) },
  7.         'cross': (x, y) => { return (x[0] * y[1]) - (y[0] * x[1]) }
  8.     }
  9. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement