PAL Mathematics: Modulo, Angles, and Wrapping

Modulo operations, degree/radian conversion, and periodic wrapping of real or complex values.

PAL Mathematics: Modulo, Angles, and Wrapping — 14 functions

KiratPalDegToRad

Signature
T_FLOAT KiratPalDegToRad(T_FLOAT fInputAngleDeg);
Description
Converts degrees to radians.
Mathematical operation
\(\theta_{rad}=\theta_{deg}\pi/180\)

KiratPalMod

Signature
T_FLOAT KiratPalMod(T_FLOAT fValue, T_FLOAT fDenom);
Description
Performs a modulo/remainder operation for the specified data type.
Mathematical operation
\(y=\operatorname{fmod}(x,d)\)

KiratPalModComCom

Signature
T_COMPLEX KiratPalModComCom(T_COMPLEX cValue, T_COMPLEX cDenom);
Description
Performs a modulo/remainder operation for the specified data type.
Mathematical operation
\(q=-z/d\) is computed as \(q=-z d^*/(|d|^2+\varepsilon_{\mathrm{SYS}})\); then \(c=\lceil\Re q\rceil+j\lceil\Im q\rceil\) and \(r=z+dc\).

KiratPalModComFloat

Signature
T_COMPLEX KiratPalModComFloat(T_COMPLEX cValue, T_FLOAT fDenom);
Description
Performs a modulo/remainder operation for the specified data type.
Mathematical operation
Equivalent to `KiratPalModComCom` with \(d=a+j0\): \(q=-z/a\) (denominator protected by \(\varepsilon_{\mathrm{SYS}}\)), component-wise ceiling, then \(r=z+a\lceil q\rceil_c\).

KiratPalModInt

Signature
T_INT KiratPalModInt(T_INT iValue, T_INT iDenom);
Description
Performs a modulo/remainder operation for the specified data type.
Mathematical operation
\(y=x\bmod d\) using the C integer remainder operator.

KiratPalRadToDeg

Signature
T_FLOAT KiratPalRadToDeg(T_FLOAT fInputAngleRad);
Description
Converts radians to degrees.
Mathematical operation
\(\theta_{deg}=\theta_{rad}180/\pi\)

KiratPalWrapMaxC

Signature
T_COMPLEX KiratPalWrapMaxC(T_COMPLEX cIn, T_COMPLEX cMax);
Description
Periodically wraps a value into the specified range.
Mathematical operation
\(r=\operatorname{mod}_{\mathbb C}(\operatorname{mod}_{\mathbb C}(z,m)+m,m)\), where \(\operatorname{mod}_{\mathbb C}\) is the PAL complex modulo based on complex division followed by component-wise ceiling.

KiratPalWrapMaxF

Signature
T_FLOAT KiratPalWrapMaxF(T_FLOAT fIn, T_FLOAT fMax);
Description
Periodically wraps a value into the specified range.
Mathematical operation
\(y=\operatorname{fmod}(x,M)\); if \(y<0\), \(y\leftarrow y+M\). Thus \(y\in[0,M)\) for \(M>0\).

KiratPalWrapMinMaxC

Signature
T_COMPLEX KiratPalWrapMinMaxC(T_COMPLEX cIn, T_COMPLEX cMin, T_COMPLEX cMax);
Description
Periodically wraps a value into the specified range.
Mathematical operation
\(r=z_{min}+\operatorname{wrapMax}_{\mathbb C}(z-z_{min},z_{max}-z_{min})\).

KiratPalWrapMinMaxF

Signature
T_FLOAT KiratPalWrapMinMaxF(T_FLOAT fIn, T_FLOAT fMin, T_FLOAT fMax);
Description
Periodically wraps a value into the specified range.
Mathematical operation
With \(R=x_{max}-x_{min}\): \(y=x_{min}+\operatorname{wrap}_{[0,R)}(x-x_{min})\), hence \(y\in[x_{min},x_{max})\) for \(R>0\).

KiratPalWrapTo180

Signature
T_FLOAT KiratPalWrapTo180(T_FLOAT fInputAngle);
Description
Periodically wraps a value into the specified range.
Mathematical operation
Repeatedly add or subtract \(360^\circ\) until \(-180^\circ\le y\le180^\circ\). The endpoints are retained because the tests are strict (\(>180\) and \(<-180\)).

KiratPalWrapTo2Pi

Signature
T_FLOAT KiratPalWrapTo2Pi(T_FLOAT fInputAngle);
Description
Periodically wraps a value into the specified range.
Mathematical operation
\(y=\operatorname{wrap}_{[0,2\pi)}(x)\).

KiratPalWrapTo2PiComplex

Signature
T_COMPLEX KiratPalWrapTo2PiComplex(T_COMPLEX cInputAngle);
Description
Periodically wraps a value into the specified range.
Mathematical operation
First compute the PAL complex modulo \(r=\operatorname{mod}_{\mathbb C}(z,2\pi+j0)\); then independently subtract \(2\pi\) from each component that exceeds \(\pi\). Thus the implementation maps the resulting real and imaginary components to approximately \((-\pi,\pi]\) under the PAL complex-modulo convention.

KiratPalWrapToPi

Signature
T_FLOAT KiratPalWrapToPi(T_FLOAT fInputAngle);
Description
Periodically wraps a value into the specified range.
Mathematical operation
Repeatedly add or subtract \(2\pi\) until \(-\pi\le y\le\pi\). The endpoints are retained because the tests are strict (\(>\pi\) and \(<-\pi\)).