private void CalculateRotMatrix(Double x, Double y)
{
var angle = this.Angle.Get(x, y) * 360.0 * Math.PI / 180.0;
var ax = this.X.Get(x, y);
var ay = this.Y.Get(x, y);
var az = this.Z.Get(x, y);
var cosangle = Math.Cos(angle);
var sinangle = Math.Sin(angle);
rotationMatrix[0, 0] = 1.0 + (1.0 - cosangle) * (ax * ax - 1.0);
rotationMatrix[1, 0] = -az * sinangle + (1.0 - cosangle) * ax * ay;
rotationMatrix[2, 0] = ay * sinangle + (1.0 - cosangle) * ax * az;
rotationMatrix[0, 1] = az * sinangle + (1.0 - cosangle) * ax * ay;
rotationMatrix[1, 1] = 1.0 + (1.0 - cosangle) * (ay * ay - 1.0);
rotationMatrix[2, 1] = -ax * sinangle + (1.0 - cosangle) * ay * az;
rotationMatrix[0, 2] = -ay * sinangle + (1.0 - cosangle) * ax * az;
rotationMatrix[1, 2] = ax * sinangle + (1.0 - cosangle) * ay * az;
rotationMatrix[2, 2] = 1.0 + (1.0 - cosangle) * (az * az - 1.0);
}