Path: chuka.playstation.co.uk!news From: "Darren Jackson" Newsgroups: scee.yaroze.beginners Subject: Re: angles, angles Date: Sun, 22 Nov 1998 19:57:17 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 79 Message-ID: <739qi2$ekm13@chuka.playstation.co.uk> References: <72spa7$dvm12@chuka.playstation.co.uk> <72sr28$dvm13@chuka.playstation.co.uk> <3652971c.228584498@news.playstation.co.uk> <731up3$olq9@chuka.playstation.co.uk> <3654E715.74C8@manc.u-net.com> NNTP-Posting-Host: pFAs07a06.client.global.net.uk X-Newsreader: Microsoft Outlook Express 4.72.3115.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 James Shaughnessy wrote in message <3654E715.74C8@manc.u-net.com>... >Darren Jackson wrote: >> ONE=4096=1degree, right? >> should I convert to degrees before using it in sin and cos? > >It depends on what your sin/cos library uses. If you use my SINCOS.H >lookup tables (see SCBUILD from my page plug plug ;-) ) then >you can divide a full circle into whatever you want, including >degrees if you wish: "scbuild 360" gives proper 'degree' tables, >so to do sin(90 degrees) just do: SIN[90] in your program. >If you use "scbuild 1024" then sin(90 degrees) is SIN[256]. >(I assume you are aware that "SIN[]" is just an array, and not >a slow maths function like "sin()") > >The result of SIN[] is multiplied by 4096 as the fixed point scaling >function (nothing to do with the angle argument which I think you >are confusing it with), so when you want to refer to it in it's "true" >form, you must bitshift it right 12 times: (SIN[angle]>>12) > >There's no reason why you should use degrees though, it's best >and more accurate to use say 1024. For more accuracy (but more >memory) use 4096 for a full circle. (SIN[4096] and COS[4096] tables >would add 32Kb to the executable so not too bad anyhoo) > >Then use a pencil to ram up your nose to mash up the part of the brain >that always wants to think in degrees. The only reason a circle was >divided into 360 was because it was "quite near" to how many days that >are in a year you know. End of history lesson. 8-) >4096 is dead easy to get used to though (1024 right-angle), just be >glad we don't have to use RADIANS! (or that mutant Gradian..) After a bit of thinking and a lot of trial and error, I came up with this, which kinda does what I want but the sprite moves way to fast. Also, I am not really sure what is going on, and I am not sure as to the accuracy (i.e. how may different paths are they between 0 and 90degrees? and how do I get more?) I am using the trig library generated by scbuild 4096. Am I on the right track? basically I want the sprite (tank) to move forward in the direction its pointing, but I want it to go quite slowly. code snippet : if (PAD & PADup } { tank1.x_speed=(SIN[tank1.sprite.rotate/360]>>9); tank1.y_speed=-(COS[tank1.sprite.rotate/360]>>9); MovePlayer(); } if (PAD & PADdown ) { } if (PAD & PADright ) { tank1.sprite.rotate+=ONE; } if (PAD & PADleft ) { tank1.sprite.rotate-=ONE; } void MovePlayer() { tank1.sprite.x += tank1.x_speed; tank1.sprite.y += tank1.y_speed; } Darren