|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#14
|
|||
|
|||
|
Re: Approximate! --- correction
Posted by Patrick Dingle at 04/13/2001 4:39 PM EST
College Student on team #639, Red B^2, from Ithaca High School and Cornell University. In Reply to: Re: Approximate! Posted by Patrick Dingle on 04/13/2001 4:28 PM EST: In case anyone actually wants to use these approximations, I made a mistake in the cosine series. It should be: sin x = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... cos x = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - ... arctan x = x - x^3/3 + x^5/5 - x^7/7 + x^9/9 - ... Also I should point out that all angles in these are in radians. 180 Degrees = Pi radians. So, one radian is about 57.296 degrees. You'll have to use these conversions if you plan on keeping track of angles in degrees. Patrick : Yay this is one of the rare occasions where you can use calculus... For virtually all functions you can find a power series that does a really good job at approximating the actual function (for example, sine, cosine, arctangent, etc...). The higher the order, the more accuracy you get. For sine and cosine, you can use only the first four terms of the series below and get a function remarkably similar to the real functions... at least for the applicable domain of angles between -180 and 180. : For example, : sin x = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... : cos x = 1 - x^2/2! + x^4/4! - x^6/5! + x^8/8! - ... : arctan x = x - x^3/3 + x^5/5 - x^7/7 + x^9/9 - ... : (! means factorial; n! = n * n-1 * n-2 * ... * 1; e.g. 5! = 5*4*3*2*1 = 120) : This area of calculus is known as Maclaurin series... check it out if you really are inspired to do so. ;p : Patrick : : Every time I think I can't live without an inverse trig : : function, I end up finding an approximation that gets : : me near enough to it without the fuss of actually : : having to use them. : : Most of the time, I am able to approximate them close : : enough with a simple linear function, but if that is : : not good enough, the lookup/lookdown functions can give : : about as complex of a function as you could want or : : need. : : Finally, if you HAVE to have it, simply devote the EEPROM : : space to defining ARCSIN, ARCCOS and ARCTAN. : : It would use up 3/8's of your code space in each : : programming slot you need the funtions, but this would : : not be too hard to manage if you break your code up : : into several slots. I think you could do it if you really : : needed it. : : Just my opinion. I have been wrong before (once ;-) : : Joe J. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A report on off season competitions | Ken Leung | Off-Season Events | 2 | 17-10-2003 13:30 |
| QotW [04-20-03]: Post-season competitions. | Madison | Rumor Mill | 16 | 26-04-2003 01:27 |
| An idea for the 2000 games..(is six weeks enough?) | archiver | 1999 | 18 | 23-06-2002 23:17 |
| Another idea looking for comments | archiver | 1999 | 16 | 23-06-2002 22:01 |
| great storyboard idea | SharkBite | 3D Animation and Competition | 0 | 15-01-2002 20:39 |