Example #1
0
        /**
         * @note Exp should really only be used after Log.
         * Assumes a quaternion with W=0 and V=theta*v (where |v| = 1).
         * Exp(q) = (sin(theta)*v, cos(theta))
         */
        public FQuat Exp()
        {
            float Angle    = (float)FMath.Sqrt(X * X + Y * Y + Z * Z);
            float SinAngle = (float)FMath.Sin(Angle);

            FQuat Result = new FQuat();

            Result.W = (float)FMath.Cos(Angle);

            if (FMath.Abs(SinAngle) >= Const.SMALL_NUMBER)
            {
                float Scale = SinAngle / Angle;
                Result.X = Scale * X;
                Result.Y = Scale * Y;
                Result.Z = Scale * Z;
            }
            else
            {
                Result.X = X;
                Result.Y = Y;
                Result.Z = Z;
            }

            return(Result);
        }