Simple vector class.
Contructor function for THRUNIUM Vector class.
var vector = new THRUNIUM.Vector(10, 20);
This clones the vector and returns it.
var vector = new THRUNIUM.Vector(10, 20);
var clonedVector = vector.clone();
console.log(clonedVector);
// outputs the cloned vector
This normalizes the vector so the length of it is one.
var vector = new THRUNIUM.Vector(10, 20);
vector.normalize();
console.log(vector);
// outputs the normalized vector
This limits the vector for exceeding a certain vector
var vector = new THRUNIUM.Vector(10, 20);
var limitVector = new THRUNIUM.Vector(10, 10);
vector.limit(limitVector);
console.log(vector);
// outputs the vector but with values (10, 10)
This scales the vector with 'scale' amount
var vector = new THRUNIUM.Vector(10, 20);
vector.scale(2);
console.log(vector);
// outputs the vector with values (20, 40)
This scales the vectors x value with 'scale' amount
var vector = new THRUNIUM.Vector(10, 20);
vector.scaleX(2);
console.log(vector);
// outputs the vector with values (20, 20)
This scales the vectors y value with 'scale' amount
var vector = new THRUNIUM.Vector(10, 20);
vector.scaleY(2);
console.log(vector);
// outputs the vector with values (10, 40)
This adds a vector to the vector
var vector = new THRUNIUM.Vector(10, 20);
var addVector = new THRUNIUM.Vector(5, 2);
vector.add(addVector);
console.log(vector);
// outputs the vector with values (15, 22)
This adds a vectors x value to the vectors x value
var vector = new THRUNIUM.Vector(10, 20);
var addVector = new THRUNIUM.Vector(5, 2);
vector.addX(addVector);
console.log(vector);
// outputs the vector with values (15, 20)
This adds a vectors y value to the vectors y value
var vector = new THRUNIUM.Vector(10, 20);
var addVector = new THRUNIUM.Vector(5, 2);
vector.addY(addVector);
console.log(vector);
// outputs the vector with values (10, 22)
This subtracts a vector from the vector
var vector = new THRUNIUM.Vector(10, 20);
var subtractVector = new THRUNIUM.Vector(2, 10);
vector.subtract(subtractVector);
console.log(vector);
// outputs the vector with values (8, 10)
This subtracts a vectors x value from the vectors x value
var vector = new THRUNIUM.Vector(10, 20);
var subtractVector = new THRUNIUM.Vector(2, 10);
vector.subtractX(subtractVector);
console.log(vector);
// outputs the vector with values (8, 20)
This subtracts a vectors y value from the vectors y value
var vector = new THRUNIUM.Vector(10, 20);
var subtractVector = new THRUNIUM.Vector(2, 10);
vector.subtractY(subtractVector);
console.log(vector);
// outputs the vector with values (10, 10)
This divides a vector with the vector
var vector = new THRUNIUM.Vector(10, 20);
var divideVector = new THRUNIUM.Vector(2, 4);
vector.divide(divideVector);
console.log(vector);
// outputs the vector with values (5, 5)
This divides a vectors x value with the vectors x value
var vector = new THRUNIUM.Vector(10, 20);
var divideVector = new THRUNIUM.Vector(2, 4);
vector.divideX(divideVector);
console.log(vector);
// outputs the vector with values (5, 20)
This divides a vectors y value with the vectors y value
var vector = new THRUNIUM.Vector(10, 20);
var divideVector = new THRUNIUM.Vector(2, 4);
vector.divideY(divideVector);
console.log(vector);
// outputs the vector with values (10, 5)
This multiplies a vector with the vector
var vector = new THRUNIUM.Vector(10, 20);
var multiplyVector = new THRUNIUM.Vector(4, 2);
vector.multiply(multiplyVector);
console.log(vector);
// outputs the vector with values (40, 40)
This multiplies a vectors x value with the vectors x value
var vector = new THRUNIUM.Vector(10, 20);
var multiplyVector = new THRUNIUM.Vector(4, 2);
vector.multiplyX(multiplyVector);
console.log(vector);
// outputs the vector with values (40, 20)
This multiplies a vectors y value with the vectors y value
var vector = new THRUNIUM.Vector(10, 20);
var multiplyVector = new THRUNIUM.Vector(4, 2);
vector.multiplyY(multiplyVector);
console.log(vector);
// outputs the vector with values (10, 40)
This inverts the vector
var vector = new THRUNIUM.Vector(10, 20);
vector.invert();
console.log(vector);
// outputs the vector with values (-10, -20)
This inverts the vectors x value
var vector = new THRUNIUM.Vector(10, 20);
vector.invertX();
console.log(vector);
// outputs the vector with values (-10, 20)
This inverts the vectors y value
var vector = new THRUNIUM.Vector(10, 20);
vector.invertY();
console.log(vector);
// outputs the vector with values (10, -20)