Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!linac!midway!msuinfo!convex.cl.msu.edu!jap From: jap@convex.cl.msu.edu (Joe Porkka) Newsgroups: comp.sys.amiga.tech Subject: Re: Integer sine calculations? Message-ID: <1990Nov23.175553.15606@msuinfo.cl.msu.edu> Date: 23 Nov 90 17:55:53 GMT References: <7336@hub.ucsb.edu> <1990Nov21.221825.10898@mdivax1.uucp> Sender: news@msuinfo.cl.msu.edu Distribution: comp Organization: Michigan State University Lines: 33 hebrais@olivier.IRO.UMontreal.CA (Philippe Hebrais) writes: > 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. I wrote aturtle graphics hack in assembly language once - it used SIN and COS for dealing with angles. How? Lookup tables and 16bit fixed point math. (32bit math with the faction point in the middle.) The lookup tables dont need to be big. I needed one decimal point of precision (i.e. ###.#) and worked with degrees (though you could do it with radians). So, 0.0 - 359.9 sounds like about 3600 32bit constants times two for each SIN and COS - right? Nope - I think I only used one 1800 32bit entry table and used that fact that SIN and COS look a lot alike, and things like sinx = -sin(360-x)