Thread: math.h library
View Single Post
  #5   Spotlight this post!  
Unread 19-12-2003, 08:18
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: math.h library

Quote:
Originally Posted by mightywombat
whats a linear table lookup?
The only issue with a table lookup is that you're confined to the values you put in your table.

You can use an approximation called the Maclaurin series for Sine, Cosine, and Tangent. The formulas are listed below. The angle, x, is in radians. There are 2*Pi radians in a circle, so 360 degrees = 2*Pi radians. These formulas match the actual Sine, Cosine, and Tangent to three decimal points.

Sine(x) = x - x^3/3! + x^5/5!
Cosine(x) = 1 - x^2/2! + x^4/4!
Tangent(x) = x + 2x^3/3! + 16x^5/5!

This is a special case of the Taylor series, which I'll leave to you look up. The Taylor series would allow you to reduce the number of terms you're calculating by using know values of Sin/Cos/Tan near the angle you're looking for.

The ! is the factorial operator and just means to take the number and multiple it by every number between it and 0.

3! = 3*2*1 = 6
4! = 4*3*2*1 = 24