public void TestRotateByUnitQuaternion()
{
double angle = Math.PI / 3.0; // half angle of 120 degree rotation
double cos = Math.Cos(angle);
double sin = Math.Sin(angle);
Cartesian axis = (new Cartesian(1.0, 1.0, 1.0)).Normalize(); // unit vector along [1,1,1]
double w = cos;
double x = sin * axis.X;
double y = sin * axis.Y;
double z = sin * axis.Z;
// The original vector is along the x-axis.
Cartesian original = new Cartesian(1.0, 0.0, 0.0);
// The rotated vector is along the z-axis.
Cartesian rotated = original.Rotate(new UnitQuaternion(w, x, y, z));
Assert.AreEqual(0.0, rotated.X, Constants.Epsilon15);
Assert.AreEqual(0.0, rotated.Y, Constants.Epsilon15);
Assert.AreEqual(1.0, rotated.Z, Constants.Epsilon15);
}