var Vector = new Native({
	name: 'Vector',
	initialize: function(x, y, z){
		this.x = x;
		this.y = y;
		this.z = z;
	}
});

Vector.implement({
	getLength: function(){
		return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
	},
	
	substract: function(other){
		return new Vector(
			this.x - other.x,
			this.y - other.y,
			this.z - other.z
		);
	},
	
	normalize: function(){
		var n = this.getLength();
		this.x /= n;
		this.y /= n;
		this.z /= n;
		return this;
	},
	
	cross: function(other){
		return new Vector(
			this.y * other.z - this.z * other.y,
			this.z * other.x - this.x * other.z,
			this.x * other.y - this.y * other.x);
	},
	
	scalarProduct: function(other){
		return this.x * other.x + this.y * other.y + this.z * other.z;
	},
	
	toString: function(){
		return "<" + [this.x, this.y, this.z].join(', ') + ">";
	}
	
});
