/// <summary>
        /// Builds a 3-D affine transformation matrix.
        /// </summary>
        /// <param name="scaling">The scaling vactor. Use zero to specify no scaling.</param>
        /// <param name="rotationCenter">A <see cref="Vector3F"/> instance specifying the center of the rotation.</param>
        /// <param name="rotation">A <see cref="QuaternionF"/> instance specifying the rotation. use <see cref="QuaternionF.Identity"/> to specify no rotation.</param>
        /// <param name="translation">A <see cref="Vector3F"/> specifying the translation. Use <see cref="Vector3F.Zero"/> to specify no translation.</param>
        /// <returns>A <see cref="Matrix4F"/> representing the affine transformation.</returns>
        /// <remarks>
        /// <p>
        /// Calculates the transoformation matrix using the following formula:
        /// Mout = Ms * (Mrc)^-1 * Mr * Mrc * Mt
        /// </p>
        /// <p>
        /// where:
        /// <list type="bullet">
        ///		<item>
        ///			<term>Ms</term>
        ///			<description>Scaling transformation.</description>
        ///		</item>
        ///		<item>
        ///			<term>Mrc</term>
        ///			<description>Rotation center transformation.</description>
        ///		</item>
        ///		<item>
        ///			<term>Mr</term>
        ///			<description>Rotation transformation.</description>
        ///		</item>
        ///		<item>
        ///			<term>Mt</term>
        ///			<description>Translation transformation.</description>
        ///		</item>
        /// </list>
        /// </p>
        /// </remarks>
        public static Matrix4F AffineTransformation(float scaling, Vector3F rotationCenter, QuaternionF rotation, Vector3F translation)
        {
            Matrix4F Ms = TransformationF.Scaling(scaling, scaling, scaling);
            Matrix4F Mt = TransformationF.Translation(translation.X, translation.Y, translation.Z);

            // TODO: Implement this.
            throw new NotImplementedException();
        }
        /// <summary>
        /// Calculates the exponent of a quaternion.
        /// </summary>
        /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
        /// <returns>The quaternion's exponent.</returns>
        public QuaternionF Exp(QuaternionF a)
        {
            QuaternionF result = new QuaternionF(0.0f,0.0f,0.0f,0.0f);

            float angle = (float)System.Math.Sqrt(a.X*a.X + a.Y*a.Y + a.Z*a.Z);
            float sin = (float)System.Math.Sin(angle);

            if (MathFunctions.Abs(sin) > 0.0f)
            {
                float coeff = angle / sin;
                result.X = coeff * a.X;
                result.Y = coeff * a.Y;
                result.Z = coeff * a.Z;
            }
            else
            {
                result.X = a.X;
                result.Y = a.Y;
                result.Z = a.Z;
            }

            return result;
        }
 /// <summary>
 /// Subtracts a quaternion from a quaternion and puts the result into a third quaternion.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="result">A <see cref="QuaternionF"/> instance to hold the result.</param>
 public static void Subtract(QuaternionF a, QuaternionF b, ref QuaternionF result)
 {
     result.W = a.W - b.W;
     result.X = a.X - b.X;
     result.Y = a.Y - b.Y;
     result.Z = a.Z - b.Z;
 }
 /// <summary>
 /// Subtracts a quaternion from a quaternion.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <returns>A new <see cref="QuaternionF"/> instance containing the difference.</returns>
 public static QuaternionF Subtract(QuaternionF a, QuaternionF b)
 {
     return new QuaternionF(a.W - b.W, a.X - b.X, a.Y - b.Y, a.Z - b.Z);
 }
 /// <summary>
 /// Converts a given <see cref="QuaternionF"/> to a matrix.
 /// </summary>
 /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
 /// <returns>A new <see cref="Matrix4F"/> instance.</returns>
 public static Matrix4F QuaternionToMatrix(QuaternionF q)
 {
     float x = q.X;
     float y = q.Y;
     float z = q.Z;
     float w = q.W;
     float xx = x * x;
     float yy = y * y;
     float zz = z * z;
     float xy = x * y;
     float xz = x * z;
     float yz = y * z;
     float wx = w * x;
     float wy = w * y;
     float wz = w * z;
     return new Matrix4F(
         1.0f - 2.0f * yy - 2.0f * zz,	2.0f * xy - 2.0f * wz,
         2.0f * xz + 2.0f * wy,			0.0f,
         2.0f * xy + 2.0f * wz,			1.0f - 2.0f * xx - 2.0f * zz,
         2.0f * yz - 2.0f * wx,			0.0f,
         2.0f * xz - 2.0f * wy,			2.0f * yz + 2.0f * wx,
         1.0f - 2.0f * xx - 2.0f * yy,	0.0f,
         0.0f,							0.0f,
         0.0f,							1.0f);
 }
 /// <summary>
 /// Multiplies a quaternion by a scalar and put the result in a third quaternion.
 /// </summary>
 /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="result">A <see cref="QuaternionF"/> instance to hold the result.</param>
 public static void Multiply(QuaternionF q, float s, ref QuaternionF result)
 {
     result.W = q.W * s;
     result.X = q.X * s;
     result.Y = q.Y * s;
     result.Z = q.Z * s;
 }
        /// <summary>
        /// Multiplies a quaternion by a scalar.
        /// </summary>
        /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <returns>A <see cref="QuaternionF"/> instance to hold the result.</returns>
        public static QuaternionF Multiply(QuaternionF q, float s)
        {
            QuaternionF result = new QuaternionF(q);
            result.W *= s;
            result.X *= s;
            result.Y *= s;
            result.Z *= s;

            return result;
        }
 /// <summary>
 /// Adds two quaternions.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <returns>A new <see cref="QuaternionF"/> instance containing the sum.</returns>
 public static QuaternionF Add(QuaternionF a, QuaternionF b)
 {
     return new QuaternionF(a.W + b.W, a.X + b.X, a.Y + b.Y, a.Z + b.Z);
 }
        /// <summary>
        /// Multiplies quaternion <paramref name="a"/> by quaternion <paramref name="b"/>.
        /// </summary>
        /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
        /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
        /// <returns>A new <see cref="QuaternionF"/> containing the result.</returns>
        public static QuaternionF Multiply(QuaternionF a, QuaternionF b)
        {
            QuaternionF result = new QuaternionF();
            result.W = a.W * b.W - a.X * b.X - a.Y * b.Y - a.Z * b.Z;
            result.X = a.W * b.X + a.X * b.W + a.Y * b.Z - a.Z * b.Y;
            result.Y = a.W * b.Y + a.Y * b.W + a.Z * b.X - a.X * b.Z;
            result.Z = a.W * b.Z + a.Z * b.W + a.X * b.Y - a.Y * b.X;

            return result;
        }
        /// <summary>
        /// Calculates the logarithm of a given quaternion.
        /// </summary>
        /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
        /// <returns>The quaternion's logarithm.</returns>
        public static QuaternionF Log(QuaternionF a)
        {
            QuaternionF result = new QuaternionF(0.0f,0.0f,0.0f,0.0f);

            if (MathFunctions.Abs(a.W) < 1.0f)
            {
                float angle = (float)System.Math.Acos(a.W);
                float sin = (float)System.Math.Sin(angle);

                if (MathFunctions.Abs(sin) >= 0.0f)
                {
                    float coeff = angle / sin;
                    result.X = coeff * a.X;
                    result.Y = coeff * a.Y;
                    result.Z = coeff * a.Z;
                }
                else
                {
                    result.X = a.X;
                    result.Y = a.Y;
                    result.Z = a.Z;
                }
            }

            return result;
        }
 /// <summary>
 /// Calculates the dot product of two quaternions.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <returns>The dot product value.</returns>
 public static float Dot(QuaternionF a, QuaternionF b)
 {
     return a.W * b.W + a.X * b.X + a.Y * b.Y + a.Z * b.Z;
 }
        /// <summary>
        /// Divides a quaternion by a scalar and put the result in a third quaternion.
        /// </summary>
        /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="QuaternionF"/> instance to hold the result.</param>
        public static void Divide(QuaternionF q, float s, ref QuaternionF result)
        {
            if(s == 0)
            {
                throw new DivideByZeroException( "Dividing quaternion by zero" );
            }

            result.W = q.W / s;
            result.X = q.X / s;
            result.Y = q.Y / s;
            result.Z = q.Z / s;
        }
        /// <summary>
        /// Divides a quaternion by a scalar.
        /// </summary>
        /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <returns>A <see cref="QuaternionF"/> instance to hold the result.</returns>
        public static QuaternionF Divide(QuaternionF q, float s)
        {
            if(s == 0)
            {
                throw new DivideByZeroException( "Dividing quaternion by zero" );
            }

            QuaternionF result = new QuaternionF(q);

            result.W /= s;
            result.X /= s;
            result.Y /= s;
            result.Z /= s;

            return result;
        }
 /// <summary>
 /// Adds two quaternions and put the result in the third quaternion.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="result">A <see cref="QuaternionF"/> instance to hold the result.</param>
 public static void Add(QuaternionF a, QuaternionF b, ref QuaternionF result)
 {
     result.W = a.W + b.W;
     result.X = a.X + b.X;
     result.Y = a.Y + b.Y;
     result.Z = a.Z + b.Z;
 }
 /// <summary>
 /// Builds a rotation matrix from a quaternion.
 /// </summary>
 /// <param name="q">A <see cref="QuaternionF"/> instance.</param>
 /// <returns>A <see cref="Matrix4F"/> representing the rotation.</returns>
 public static Matrix4F RotationQuaternion(QuaternionF q)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
 /// <summary>
 /// Multiplies quaternion <paramref name="a"/> by quaternion <paramref name="b"/> and put the result in a third quaternion.
 /// </summary>
 /// <param name="a">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="b">A <see cref="QuaternionF"/> instance.</param>
 /// <param name="result">A <see cref="QuaternionF"/> instance to hold the result.</param>
 public static void Multiply(QuaternionF a, QuaternionF b, ref QuaternionF result)
 {
     result.W = a.W * b.W - a.X * b.X - a.Y * b.Y - a.Z * b.Z;
     result.X = a.W * b.X + a.X * b.W + a.Y * b.Z - a.Z * b.Y;
     result.Y = a.W * b.Y + a.Y * b.W + a.Z * b.X - a.X * b.Z;
     result.Z = a.W * b.Z + a.Z * b.W + a.X * b.Y - a.Y * b.X;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QuaternionF"/> class using coordinates from a given <see cref="QuaternionF"/> instance.
 /// </summary>
 /// <param name="q">A <see cref="QuaternionF"/> to get the coordinates from.</param>
 public QuaternionF(QuaternionF q)
 {
     _w = q.W;
     _x = q.X;
     _y = q.Y;
     _z = q.Z;
 }