1. ## Calculating inverse tangent

I need to compute inverse tangents, and I can't find any information on the net on how to do this. I am using C.

2. http://mathworld.wolfram.com/InverseTangent.html
In the GNU C library, it is implemented as atan(double x).
Code:
```#include <stdio.h>
#include <math.h>
int main(void)
{
double x, y;
x = 1.0;
y = tan(x);
printf ("Remember this is in Radians\n%f\n%f\n", x, y);
printf ("%f\n", atan(y) );
return 0;
}```
For values >2pi or <-2pi you have to do some more calculations.

3. No, I can't use the standard library, I have to code my own. My robot controller doesn't have any math functions in it's standard library.

4. Might want to specify something like that next time. Which robot type? GCC is able to port out a lot of code to other platforms includeing some embedded ones.

Just spoke with my instructor. He has done quite a bit of embedded programming and does a robot course here at the college. What I got from him is that once GCC gets done making the executable it is self contained as far as the code. So as long as the processor can proform the basic operations and you set the correct flags for the platform it should run.

Behold the power that is GCC

5. I'm using the Microchip PIC18F8520

6. Umm can't u use sequences and series (taylor maclaren) from calculus to find inverse tan

7. We got it working at about 1:00 AM last night. All I have left to code is the rotation code and I'll have autonomous going for our robot.

8. Once you get done I'd be interested in the code. BTW I wasn't trying to be an ass, it just comes naturally.

9. Originally posted by KneeGrow
Umm can't u use sequences and series (taylor maclaren) from calculus to find inverse tan
Exactly my idea.

Add up all of the following for an approximation. The more terms you use, the more accurate your result.

x-x^3/3+x^5/5-x^7/7...

10. Of course if you wanted speed over size you could just do a table lookup

11. If we did a table lookup we would have over 2000 values in it. That is what our original plan was until we realized that.

12. Use binary search in conjunction with a lookup table and it'll be fairly quick. Its all a matter of space vs speed