function vector(in_x, in_y, in_z)
{
	this.x=in_x;
	this.y=in_y;
	this.z=in_z;
}

vector.prototype.clone = function()
{
	return new vector(this.x, this.y, this.z);
}

vector.prototype.scale = function(val)
{
	this.x *= val;
	this.y *= val;
	this.z *= val;
	
	return this;
}

vector.prototype.negate = function()
{
	return new vector(-this.x, -this.y, -this.z);
}

vector.prototype.add_eq = function(in_v)
{
	this.x += in_v.x;
	this.y += in_v.y;
	this.z += in_v.z;
	
	return this;
}

function vec_add(vec1, vec2)
{
	return new vector(vec1.x+vec2.x, vec1.y+vec2.y, vec1.z+vec2.z);
}

function dot_prod(vec1, vec2)
{
	return vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z;
}

function cross_prod(vec1, vec2)
{
	return new vector(	vec1.y*vec2.z - vec1.z*vec2.y,
						vec1.z*vec2.x - vec1.x*vec2.z,
						vec1.x*vec2.y - vec1.y*vec2.x );
}

vector.prototype.len_sq = function()
{
	return dot_prod(this, this);
}

vector.prototype.length = function()
{
	return Math.sqrt(this.len_sq());
}

vector.prototype.normalize = function()
{
	return this.scale(1 / this.length());
}
