Skip to content

Problems with angle wrapping

Affects:

  • functionality using EFAP or VBAP with DOA input not in the specified range of (-180, 180] azimuth and [-90, 90] elevation
  • should be bitexact for most cases except where wrapping is required

Problems:

  • possible infinite loop in panning_wrap_angles:
if ( ( ele != 0 ) && ( fmodf( ele, 90 ) == 0 ) )
    {
        azi = 0;
        while ( fabsf( ele ) > 90 )
        {
            ele -= 360;
        }
    }

If ele is a multiple of 180 it enters this if clause and never exits the exit loop since the abssolute value is always larger than 90 and each time 360 is subtracted which increases the absolute value (after some iterations).

Example: 180 -> abs(180-360)=abs(-180)>90) -> abs(-180-360)=abs(-540)>90) -> ...

Solution add "&& fmodf(ele, 180)!= 180" to if

  • jumps in elevation in same function:
while ( fabsf( ele ) > 90 )
        {
            azi += 180;

            if ( ele > 90 )
            {
                ele -= 180;
            }
            else if ( ele < -90 )
            {
                ele += 180;
            }
        }

This code leads to jumps from one tho the other hemisphere while continuous trajectories are desired.

Example path over head: ele=[80, 90, 100], azi=[0, 0, 0] results it ele[80, 90, -80], azi=[0, 0, 180] where the last point lies on the southern hemisphere and not the northern anymore. Same for ele < -90.

Solution: "ele=180-ele" and "ele=-180-ele", respectively

Edited by Archit Tamarapu