Arcsine/Arccosine Lookup Table?
Carl Lawhon
Posts: 36
Does anyone have a lookup table for the inverse trig functions? I basically need to be able to calculate an angle given x and y cartesian coordinates. Thanks in advance for your help.
Carl Lawhon
EDIT: I neglected to mention that I would like to be able to determine angles in all four quadrants, not just 0 to 90 degrees.
Post Edited (Carl Lawhon) : 2/14/2009 2:06:17 AM GMT
Carl Lawhon
EDIT: I neglected to mention that I would like to be able to determine angles in all four quadrants, not just 0 to 90 degrees.
Post Edited (Carl Lawhon) : 2/14/2009 2:06:17 AM GMT
Comments
·
Try this and see if it will work for you.· It uses a free COG to temporarily launch an Assembly routine to calculate the·Angle.· When it's done it frees the COG.· The CORDIC routine was originally written by Chip Gracey·so my understanding of it is somewhat limited.· I also did a successive approximation reverse Sine table lookup that basically plays the classic game... "pick a number between 1 and 100" ...but it finds the answer in the least number of possible guesses.· I'll try to dig that up and wrap a·callable routine around that as well.
·
··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 2/14/2009 5:16:41 AM GMT
Second, there are two ways to compute any function. One is by power series or other math formula. The second is table lookup. I almost always tend to use math formulas, but in these days of big memory space, sometimes a table is better. It's almost always FASTER, if done properly.
Third, the power series for arctan converges even slower than the one for arcsine. Instead, use the continued-fraction form. It converges VERY fast, to the extent that you only need about third order for many uses (like yours).
Fourth, no matter how you do it, you'll need to use the function in segments. The tangent function goes to infinity, after all, at 90 degrees. In your case, by comparing the x- and y-axis values, you can always find an argument with abs value less than or equal to 1.
To see the problem done ad infinitum, with multiple segments, ultra-simple formulas, and coefficients optimized using minimax techniques, see my book, "Math Toolkit":
http://www.amazon.com/Math-Toolkit-Real-Time-Programming-Crenshaw/dp/1929629095
Jack
I'm asking because I've been working on making a more efficient use of cogs to handle accelorometers/gyros, but I really don't know what I'm doing. Are kalman filters necessary, and are there any other alternatives?
Here is the Cordic routine that I posted earlier with a reverse lookup ArcSine routine that I mentioned as well added.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Jay, the stuff on trig functions is all algebra (and trig, of course). No calculus. The second half of the book is _ALL_ calculus, but it starts at a very fundamental level, and works its way up. My whole teaching style is to make sure that "No child is left behind," and that's the way the book is written.
I feel that I should explain why I don't just post the arctan on my web site: I don't have a web site . I'm working on it, and intend to post all kinds of goodies there.
Re the gyros, etc.: I wrote a series in Embedded Systems called "Secrets of the Spin Doctors":
"Secrets of the Spin Doctors," Embedded Systems Programming, Vol. 7, #4, April 1994, pp. 40-63.
"More Secrets of the Spin Doctors," Embedded Systems Programming, Vol. 7, #5, May 1994, pp. 58-67.
"Spin Doctors at Work," Embedded Systems Programming, Vol. 7, #7, July 1994, pp. 54-73.
I think this series might be just what you need. I _THINK_ it's on the ESD CDROM, but you'd better check first.
I have tons of algorithms and models to do attitude calculations. I plan to post them, too, Real Soon Now. Eventually, I hope to be able to offer Spin versions to the library here. Real Soon Now.
Jack