delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/31/05:07:29

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro and interrupts: Again!
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <4828es0ll3ist51du5s8o8svd1g0g6l6sv@4ax.com>
References: <38E3B107 DOT 52690C10 AT tiscalinet DOT it>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 32
X-Trace: /bQNue1FQFKaNlW/IWziWKLs2WofZPfiLAloMY7IqIpz3e4/BrcV5YR/CVevLIkDF4Z6OuM8m7o7!S1WJtxBcRXm1ldJ7oSG5KI8yCqOq8D425tUXJCLHxhucQcIGZrkcdzeFEsOqP2n2vDCbS4Q6YZvK!gILCU8w=
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Fri, 31 Mar 2000 02:16:06 GMT
Distribution: world
Date: Fri, 31 Mar 2000 02:16:06 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 30 Mar 2000 21:54:47 +0200, night DOT walker AT tiscalinet DOT it wrote:

>>>I must call sin() inside a timer function (i can't use a LUT,
>>>would be too inaccurate...)
>
>Damian Yerrick wrote:
>>Would cubic interpolation on a lookup table with 1,024 entries be too
>inaccurate?
>
>Of course not! That would be PERFECT!!!
>.......
>WHAT is a cubic interpolation?  :-)

I don't have the formula handy, but you fit a cubic polynomial to
four points from the lookup table, and then read off the value.
Look for it in any numerical math textbook, or look for it on Google.

If you don't want to go that far, just do basic linear interpolation.

Given x is in units of the lookup table, do "lerp" thus:
sin(x) = sintable[floor(x)] +
         (sintable[ceil(x)] - sintable[floor(x)]) * (x - floor[x])
replacing floor and ceil with appropriate fixed-point to integer
conversions.

-- 
Damian Yerrick
"I refuse to listen to those who refuse to listen to reason."
See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019