Subject:
|
Re: Dumb math question related to Navigation and encoders
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 5 May 1999 20:12:34 GMT
|
Original-From:
|
Will Bain <WILLBAIN@CS.saynotospamUMT.EDU>
|
Viewed:
|
805 times
|
| |
| |
Bob_Kelly/First_Union@firstunion-reit.com wrote:
> How do you compute, using Handyboard Interactive C, the Sin, Cos, Tan,
> Arctan, etc. ?
This is actually a very good question.
Generally, math function libraries use what is called a Taylor series
expansion of a trigonometric function to return an approximation to the
function with arbitrary precision. The more terms from the series that
you add up, the more accurate the approximation.
The first few terms for the Taylor series expansion of arctan(x) are:
x - (1/3)x^3 + (1/5)x^5 - (1/7)x^7 + (1/9)x^9 - (1/11)x^11 + ...
The resulting angle is in radians. This series will converge for x < 1
(if x is greater than 1, you can compute the series for 1/x, to give
pi/2 radians minus the angle you're looking for).
You could write a function that returns the series out to the first few
terms, and it would probably be close enough to arctan(x) to use for
dead reckoning. For example, if x is 0.5773... (i.e., the angle is pi/6
= 30 degrees), then the last term above equals about 0.0002 radians
(about 0.01 degrees). If you use a divide & conquer method for the
exponentiation, you could compute many terms in the series fairly
efficiently.
-- Will
, ,
__@_/ \_@__ |/
| /__, o @_/
)\ ) ( \ (\/\\,
~~~~~~~~~ ' ` ~~~~~~~~~~~ ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wendy Parson, Idealism is fine, but as it approaches reality
Will Bain, the cost becomes prohibitive.
& Tatoosh --William F. Buckley, Jr.
|
|
Message is in Reply To:
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|