Skip to content

Instantly share code, notes, and snippets.

@jhohlfeld
Last active August 29, 2015 14:05
Show Gist options
  • Save jhohlfeld/5c3cae4393f0baf5c206 to your computer and use it in GitHub Desktop.
Save jhohlfeld/5c3cae4393f0baf5c206 to your computer and use it in GitHub Desktop.
<!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>
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