public Quaternion Log()
{
// BLACKBOX: Learn this
// If q = cos(A)+sin(A)*(x*i+y*j+z*k) where (x,y,z) is unit length, then
// log(q) = A*(x*i+y*j+z*k). If sin(A) is near zero, use log(q) =
// sin(A)*(x*i+y*j+z*k) since sin(A)/A has limit 1.
// start off with a zero quat
Quaternion result = Quaternion.Zero;
if ( Utility.Abs( w ) < 1.0f )
{
Real angle = (Real)Utility.ACos( w );
Real sin = Utility.Sin( angle );
if ( Utility.Abs( sin ) >= EPSILON )
{
Real coeff = angle / sin;
result.x = coeff * x;
result.y = coeff * y;
result.z = coeff * z;
}
else
{
result.x = x;
result.y = y;
result.z = z;
}
}
return result;
}