Skip to content

Fix angle calculation in calculate_channel_gains()#30

Merged
icculus merged 1 commit intoicculus:mainfrom
ivan-mogilko:fix--spatial-conditional-radians
Jan 11, 2025
Merged

Fix angle calculation in calculate_channel_gains()#30
icculus merged 1 commit intoicculus:mainfrom
ivan-mogilko:fix--spatial-conditional-radians

Conversation

@ivan-mogilko
Copy link
Contributor

This fixes angle calculation in calculate_channel_gains() in case mags is zero.

Prior to a9e2f30 the radians were calculated as:

 radians = (mags == 0.0f) ? 0.0f : SDL_acosf(dotproduct(at, rotated) / mags);

After that commit radians are no longer zeroed in case (mags == 0.0f), cosangle is zeroed instead, but radians are still calculated using SDL_acosf(cosangle), which results in Pi/2 in case there's no actual rotation.

Prior to a9e2f30 the radians were calculated as:

     radians = (mags == 0.0f) ? 0.0f : SDL_acosf(dotproduct(at, rotated) / mags);

After that commit radians are no longer zeroed in case (mags == 0.0f),
cosangle is zeroed instead, but radians are still calculated using SDL_acosf(cosangle),
which results in Pi/2 in case there's no actual rotation.
@icculus icculus merged commit fd7e70a into icculus:main Jan 11, 2025
3 checks passed
@ivan-mogilko ivan-mogilko deleted the fix--spatial-conditional-radians branch January 11, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants