Skip to content

Instantly share code, notes, and snippets.

@eduardmathmed
eduardmathmed / Vector.js
Created February 12, 2020 13:11 — 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);
};