Article View: comp.sys.amiga.tech
Article #6930Re: Integer sine calculations?
From: Philippe Hebrais
Date: Fri, 23 Nov 1990 07:42
Date: Fri, 23 Nov 1990 07:42
35 lines
1989 bytes
1989 bytes
In article <7336@hub.ucsb.edu> 6600mage@ucsbuxa.ucsb.edu (Orion Wilson the Passable) writes:
> .. Have you seen these hacker demos where
>the balls or whatever follow sinusoidal paths around
>the screen? And where there are HUNDREDS of balls
>all going very smoothly through what appear to be
>complex hypo-cycloids and such?
>My question is how these paths are computed. The
>number of objects and their speed incidates that
>they aren't being done by floating-point techniques,
>and i'm pretty sure the numbers are not
>pre-calculated, so it seems that smooth curves like
>the sin and cos can be done using integer (native
>MC68000) arithmatic.
Hmmm, seems to me you could just evaluate the Taylor series
for sine and cos in fixed point arithmetic. And also wouldn'it be
faster to compute the pair (sine, cosine) than to compute sine and
then cosine.
sin(x) = 1 - (x^2)/2! + (x^4)/4! - (x^6)/6! + ...+ (-1)^k*(x^(2k))/(2k)!
cos(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7! + ...+ (-1)^k*(x^(2k+1))/(2k+1)!
Also, don't forget that all the balls follow the same trajectory so you need
only worry with the "lead" ball.
(off course, "x^n" means "x" to the power of "n" and "5!" is "1*2*3*4*5",
that is "n!" is "n factorial")
--
Philippe Hebrais hebrais@IRO.UMontreal.CA
phil@MirkWood.CAM.ORG
FREE CANADA uunet!philmtl!iros1!phaze!mirkwood!phil
TRADE MULRONEY Voice: 514-731-9146
Technical Details
Message-ID:
<HEBRAIS.90Nov23024202@olivier.IRO.UMontreal.CA>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!IRO.UMontreal.CA!IROS1!hebraisReferences:
<7336@hub.ucsb.edu> <1990Nov21.221825.10898@mdivax1.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!IRO.UMontreal.CA!IROS1!hebrais From: hebrais@olivier.IRO.UMontreal.CA (Philippe Hebrais) Newsgroups: comp.sys.amiga.tech Subject: Re: Integer sine calculations? Message-ID: <HEBRAIS.90Nov23024202@olivier.IRO.UMontreal.CA> Date: 23 Nov 90 07:42:02 GMT References: <7336@hub.ucsb.edu> <1990Nov21.221825.10898@mdivax1.uucp> Sender: news@IRO.UMontreal.CA Distribution: comp Organization: Universite de Montreal Lines: 35