'use strict';

function Vector3(x, y, z) {
  this.x = x;
  this.y = y;
  this.z = z;
}

Vector3.prototype.invert = function () {
  this.x = -this.x;
  this.y = -this.y;
  this.z = -this.z;
};

Vector3.prototype.magnitude = function () {
  return Math.sqrt(this.squareMagnitude());
};

Vector3.prototype.squareMagnitude = function () {
  return this.x * this.x + this.y * this.y + this.z * this.z;
};

Vector3.prototype.normalize = function () {
  var l = this.magnitude();
  this.x /= l;
  this.y /= l;
  this.z /= l;
};

Vector3.prototype.multiply = function (n) {
  this.x *= n;
  this.y *= n;
  this.z *= n;
};

Vector3.prototype.multiplyCopy = function (n) {
  return new Vector3(this.x * n, this.y * n, this.z * n);
};

Vector3.prototype.sum = function (v) {
  this.x += v.x;
  this.y += v.y;
  this.z += v.z;
};

Vector3.prototype.sumCopy = function (v) {
  return new Vector3(this.x + v.x, this.y + v.y, this.z + v.z);
};

@@ -918,12 +918,229 @@
  + v.z);%0A%7D;%0A
+%0AVector3.prototype.substract = function (v) %7B%0A  this.x -= v.z;%0A  this.y -= v.y;%0A  this.z -= v.z;%0A%7D;%0A%0AVector3.prototype.substractCopy = function (v) %7B%0A  return new Vector3(this.x - v.x, this.y - v.y, this.z - v.z);%0A%7D;%0A

Add vector substraction