I try to determine the angle from a point (n,m) to (0,0). Without arctan2 being available, I’m running into the problem that m can be 0, which leads to a possible division by zero.
What would be an elegant, correct solution to tackling this issue?
don’t use the conventional quadrants, use the branch points defined by the lines y = +/- x, and use the 1st two steps of a CORDIC-like algorithm (e.g. rotate coordinates by a known angle and keep track of how much you’ve rotated):
the reason for doing it this way is that atan() may be more likely to be accurate for ratios y/x between -1 and +1, than for ratios greater than 1. (though a good atan() algorithm would recognize this and take the reciprocal)