Hi,
I've noticed that when I pass values very close to zero to atan2 it still gives an angle of +/- 180 degrees or +/- 90 degrees. But KDE's calculator's atan gives zero for the same inputs. Also the book I am reading (Understanding Digital Signal Processing) gives zeroes in the example I am working through.
I'm guessing these are floating point errors? Though I am surprised because I'm using double precision floats.
I made a hack "atan2" where I test for both values having a magnitude below 0.001 and it works (gives the same answers as the book) - however it is just that: a hack that I'm concerned may come back to bite me.
Any thoughts or suggestions?
I've noticed that when I pass values very close to zero to atan2 it still gives an angle of +/- 180 degrees or +/- 90 degrees. But KDE's calculator's atan gives zero for the same inputs. Also the book I am reading (Understanding Digital Signal Processing) gives zeroes in the example I am working through.
I'm guessing these are floating point errors? Though I am surprised because I'm using double precision floats.
I made a hack "atan2" where I test for both values having a magnitude below 0.001 and it works (gives the same answers as the book) - however it is just that: a hack that I'm concerned may come back to bite me.
Any thoughts or suggestions?