Created
August 19, 2014 13:11
-
-
Save jhohlfeld/4faa6aa6fbc2316c2805 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/hubip/1
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var Vector = function(x, y) { | |
this.x = x; | |
this.y = y; | |
this.length = Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2)); | |
}; | |
Vector.prototype.plus = function (vector) { | |
return new Vector(this.x+vector.x, this.y+vector.y); | |
}; | |
Vector.prototype.minus = function (vector) { | |
return new Vector(this.x-vector.x, this.y-vector.y); | |
}; | |
</script> | |
</body> | |
</html> |
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
var Vector = function(x, y) { | |
this.x = x; | |
this.y = y; | |
this.length = Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2)); | |
}; | |
Vector.prototype.plus = function (vector) { | |
return new Vector(this.x+vector.x, this.y+vector.y); | |
}; | |
Vector.prototype.minus = function (vector) { | |
return new Vector(this.x-vector.x, this.y-vector.y); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment