﻿

Vector4.prototype.X = 0;
Vector4.prototype.Y = 0;
Vector4.prototype.Z = 0;
Vector4.prototype.W = 0;

function Vector4(x, y, z, w)
{
	this.X = x;
	this.Y = y;
	this.Z = z;
	this.W = w;
}

Vector4.prototype.ProjectionToScreenCoordinates = function(width, height, pIn)
{
	var pOut = new Vector4(0, 0, 0, 0);
	var halfWidth = width / 2;
	var halfHeight = height / 2;
	var aspectRatio = height / width;
	pOut.W = 1.0 / pIn.W;
	pOut.X = halfWidth * (pIn.X * pOut.W + 1.0);
	pOut.Y = halfHeight - aspectRatio * halfWidth * pIn.Y * pOut.W;
	pOut.Z = pIn.Z * pOut.W;
	return pOut;
}

