ERIS CORE

◆ normalized_atan2()

float normalized_atan2 ( float  y,
float  x 
)

Definition at line 52 of file eris_analyze_fft1024.cpp.

53 {
54  //return 0;
55  static const uint32_t sign_mask = 0x80000000;
56  static const float b = 0.596227f;
57 
58  uint32_t ux;
59  uint32_t uy;
60  memcpy(&ux, &x, sizeof(x));
61  memcpy(&uy, &y, sizeof(x));
62  // Extract the sign bits
63  //uint32_t ux_s = sign_mask & (uint32_t &)x;
64  //uint32_t uy_s = sign_mask & (uint32_t &)y;
65  uint32_t ux_s = sign_mask & ux;
66  uint32_t uy_s = sign_mask & uy;
67 
68  // Determine the quadrant offset
69  float q = (float)( ( ~ux_s & uy_s ) >> 29 | ux_s >> 30 );
70 
71  // Calculate the arctangent in the first quadrant
72  float bxy_a = ::fabs( b * x * y );
73  float num = bxy_a + y * y;
74  float atan_1q = num / ( x * x + bxy_a + num );
75 
76  uint32_t uatan;
77  memcpy(&uatan, &atan_1q, sizeof(atan_1q));
78  // Translate it to the proper quadrant
79  uint32_t uatan_2q = (ux_s ^ uy_s) | uatan;
80  memcpy(&atan_1q, &uatan_2q, sizeof(uatan_2q));
81  return q + atan_1q;
82 }

Referenced by erisAudioAnalyzeFFT1024::analyze().

+ Here is the caller graph for this function: