ducha-aiki/fast_atan2

atan2LUT function, divide by zero issue

Opened this issue · 0 comments

if y or x is zero, then one of

atan_idyx = (int) ( 255*(absy/absx) );
atan_idxy = (int) ( 255*(absx/absy) );

gives us div by zero error, is it really OK without the zero check?

so in my case, I add following context (which I found in atan2LUT_if )

absy = fabsf(y);
absx = fabsf(x);

if( absy - absx == absy ) {
	  return (y < 0 ? PI_1_2_N : PI_1_2);
}
if (absx - absy == absx) {
      return (x > 0? 0.0f: PI_P);
}

please let us know whether atan2LUT has no further errors. it was really helpful.

  • ahtz