Skip to content

Instantly share code, notes, and snippets.

@raonioliver
raonioliver / Vector.js
Last active January 11, 2018 14:23 — forked from jjgrainger/Vector.js
A simple Vector class in javascript
var Vector = function(x, y) {
this.x = x || 0;
this.y = y || 0;
};
// return the angle of the vector in radians
Vector.prototype.getDirection = function() {
return Math.atan2(this.y, this.x);
};