public float[] TransformVector(float[] vector, bool normalize)
{
if (vector == null || (vector.Length < 4))
{
throw new ArgumentException();
}
var temp = new float[4];
for (int x = 0; x < 4; x++)
{
temp[x] = 255.0f * this._matrix[4, x];
for (int y = 0; y < 4; y++)
{
temp[x] += vector[y] * this._matrix[y, x];
}
}
for (int x = 0; x < 4; x++)
{
vector[x] = temp[x];
if (normalize)
{
if (vector[x] < 0) vector[x] = 0.0f;
else if (vector[x] > 255.0f) vector[x] = 255.0f;
}
}
return vector;
}