pub fn atan2_precise_fixed<T>(y: T, x: T) -> Twhere
T: Fixed,
Expand description
Calculate atan(y/x) using a polynomial approximation. Utilizes the following polynomial to estimate the angle θ [radians].
atan(y,x) = ((y,x)+0.372003(y,x)^3) / (1+0.703384(y/x)^2 + 0.043562(y/x)^4)
The method is accurat within 0.003 degrees when |θ|<=π/4.
[1] R. G. Lyons, Streamlining Digital Signal Processing, Second Etition, IEEE Press, 2012.
§Arguments
y
- Is the argument along the y or imaginary axis.x
- Is the argument along the x or real axis.
§Example
use fixed::{types::extra::U28, FixedI32};
use integer_array::utility as util;
let arg = util::atan2_precise_fixed( FixedI32::<U28>::from_num(0.6), FixedI32::<U28>::from_num(0.4) );
assert_eq!{ arg.to_num::<f32>(), 0.983006064 };