[A83] Re: fixed point numbers


[Prev][Next][Index][Thread]

[A83] Re: fixed point numbers




At 04:56 PM 4/29/01 +0200, you wrote:
>I have a sprite that moves around the screne with a certain speedvector.  So
>every frame i have to increase my x and y coordinates using the sinus and
>cosinus of that speedvector
>Last week i was talking to Crashman, and he told me to do it with a look up
>table for sinus and cosinus.  He told me also to work with fixed point
>numbers (so i would place the part after the comma in that look up table
>(the part before the comma is most of the time zero, so i don't have to put
>it in another table)). But i'm not sure how to work with those fixed point
>numbers, here's the two options i've come up with (maybe there's a better,
>that's way i ask you guys)
>1.      Say you have the number 0.531287 as a sinus,

<snip>

I think that four decimal places would be precise.  So you could store the 
first 2 places of the sine in one location, then the next two in the 
consecutive byte.  The problem you are going to have is that the actual X 
and Y coordinates are not precise enough.  You must not only keep the X and 
Y coords as a 1 byte integer, but they must be 3 bytes (1 that you use, and 
the other two which you add the numbers you get from the sine table, as a 
sort of carry).

-harper




References: