Math387.FixAngle / FixAnglef Method

Overload List

#SignatureDescription
1function FixAngle(const ThetaRad: Double): Double;Fast angle reduction to [-Pi,Pi].
2function FixAnglef(const ThetaRad: Single): Single;

Overload 1: function FixAngle(const ThetaRad: Double): Double;

Fast angle reduction to [-Pi,Pi].

#NameTypeDescription
1ThetaRadDouble

Returns: Double - Returns ThetaRad reduced to the [-Pi,Pi] interval.

Remarks:

Neither FixAngle nor Rem(x, 2*Pi) are suitable for angle reduction of large arguments. Both use the double-precision 2*Pi constant (~53 bits), so the accumulated constant error n * ulp(2*Pi) grows with magnitude: ~1e-10 rad at |x|=1e6, ~0.14 rad at |x|=1e15, meaningless above |x|=1e16. Sin, Cos and Tan handle large arguments internally using Payne-Hanek range reduction with an extended-precision 2/Pi table (hundreds of bits), which preserves full double precision regardless of input magnitude.

FixAngle should not be used before passing values to trigonometric functions. For arguments above 1E+6 it would corrupt result, and there is no performance advantage either when calling sin(FixAngle(x)) in compare to just sin(x).

Overload 2: function FixAnglef(const ThetaRad: Single): Single;

#NameTypeDescription
1ThetaRadSingle

Returns: Single