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.
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.
http://mathworld.wolfram.com/InverseTangent.html
In the GNU C library, it is implemented as atan(double x).For values >2pi or <-2pi you have to do some more calculations.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; }
BTW: That link was the first link on a google search of inverse tangent
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.
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
Last edited by Thantos; 02-24-2004 at 07:07 PM.
I'm using the Microchip PIC18F8520
Download http://www.microchip.com/download/li...ecs/39583b.pdf and read page 304
Umm can't u use sequences and series (taylor maclaren) from calculus to find inverse tan
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.
Once you get done I'd be interested in the code. BTW I wasn't trying to be an ass, it just comes naturally.
Exactly my idea.Originally posted by KneeGrow
Umm can't u use sequences and series (taylor maclaren) from calculus to find inverse tan
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...
Of course if you wanted speed over size you could just do a table lookup
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.
Use binary search in conjunction with a lookup table and it'll be fairly quick. Its all a matter of space vs speed