From 56641d5838cba59fa55d82af2e0d495185b227cc Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Thu, 17 Dec 2020 10:02:35 -0800 Subject: [PATCH] atan2: specify why we cannot use more than 15 bits for the atan argument --- dsp/src/trig.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dsp/src/trig.rs b/dsp/src/trig.rs index 53aecfa..6d0acff 100644 --- a/dsp/src/trig.rs +++ b/dsp/src/trig.rs @@ -57,7 +57,9 @@ pub fn atan2(y: i32, x: i32) -> i32 { // We need to share the 31 available non-sign bits between the // atan argument and constant factors used in the atan // approximation. Sharing the bits roughly equally between them - // gives good accuracy. + // gives good accuracy. Additionally, we cannot increase the + // number of atan argument bits beyond 15 because we must square + // it. const ATAN_ARGUMENT_BITS: usize = 15; let ratio = (min << ATAN_ARGUMENT_BITS) / max;