From 52224f8bb87b724eb3c97605c37283f032937c9e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 1 Jan 2023 22:15:46 -0800 Subject: Multiply by the inverse instead of divide --- core/hrtf.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/hrtf.cpp b/core/hrtf.cpp index 310b7a80..076d62d5 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -180,8 +180,8 @@ struct IdxBlend { uint idx; float blend; }; */ IdxBlend CalcEvIndex(uint evcount, float ev) { - ev = (al::numbers::pi_v*0.5f + ev) * static_cast(evcount-1) / - al::numbers::pi_v; + ev = (al::numbers::pi_v*0.5f + ev) * static_cast(evcount-1) * + al::numbers::inv_pi_v; uint idx{float2uint(ev)}; return IdxBlend{minu(idx, evcount-1), ev-static_cast(idx)}; @@ -192,8 +192,8 @@ IdxBlend CalcEvIndex(uint evcount, float ev) */ IdxBlend CalcAzIndex(uint azcount, float az) { - az = (al::numbers::pi_v*2.0f + az) * static_cast(azcount) / - (al::numbers::pi_v*2.0f); + az = (al::numbers::pi_v*2.0f + az) * static_cast(azcount) * + (al::numbers::inv_pi_v*0.5f); uint idx{float2uint(az)}; return IdxBlend{idx%azcount, az-static_cast(idx)}; -- cgit v1.2.3