Hello!
That's why we have atan2() function. It's already handling the atan() discontinuities.
I know, but in any case, you're going to end up with very large values when approaching from
the discontinuities when you calculate the ratio. That's why in all the encoders I know, the 45
degrees quadrants approach I was mentioning is used. By this method, you only get numbers
between -1 and +1 (-π/4 ~ π/4 on the other axis), which is very handy when using fixed point
arithmetic or even integers.
Take a look at the original set of data.
That is incorrect.
Just see the plot of tan(x) vs x:
View attachment 156682
(we cannot plot ±∞ and the graph is cropped).
It is not easy to use a LUT for tan(x).
I disagree, what I said is perfectly correct. You may consider reading my post
before claiming I'm wrong.
I was talking of tan, taken in shifted quadrants (from -π/4 to π/4, see my post
above), in which case you have only tan values between -1 and 1. You can then use
the symmetry to reduce further to 1/8 of a circle (0, π/4).
In this case, it's extremely easy to use a LUT, which gives you values that can be
used in fixed point or integer.
The symmetry around π/4 allows to use tan((π/2) -x) to find the angle in the
interval [π/4, π/2], and then the other symmetries for x and y are just a matter of sign.
Now, for the easy / not easy issue, that's really a matter of taste / ability.
What I meant is that this lookup table is not more difficult to make than any other LUT.
Dora.