/** * @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); }
/** * @return quaternion with W=0 and V=theta*v. */ public FQuat Log() { FQuat Result = new UnrealEngine.FQuat(); Result.W = 0.0f; if (FMath.Abs(W) < 1.0f) { float Angle = (float)FMath.Acos(W); float SinAngle = (float)FMath.Sin(Angle); if (FMath.Abs(SinAngle) >= Const.SMALL_NUMBER) { float Scale = Angle / SinAngle; Result.X = Scale * X; Result.Y = Scale * Y; Result.Z = Scale * Z; return(Result); } } Result.X = X; Result.Y = Y; Result.Z = Z; return(Result); }