Sign in to follow this  
Sik_the_hedgehog

Hey, the rotations don't work!

Recommended Posts

slicer4ever    6760


yea, I could see this working if you needed to condense rotations into an single byte, and didn't need very high precesion for rotatin, of course u'd probably have to use a bit to represent which half of a circle you are rotating around.

The trick is that 256 = full circle. This has the extra advantage that wraparound happens on its own (255 + 1 = 0 if the value is a byte). Given that in games usually you don't need that much accuracy, but you need performance a lot, on old systems this was pretty common. If you could afford the space another one was 65536 = full circle (16-bit angles, I know Allegro had used this).

 

arg, of course 256 is a full circle, i feel like such a fool for suggesting to use a special bit.  it's cool to hear that retro systems did legitimately use this.

Share this post


Link to post
Share on other sites
DekuTree64    1168

I use 65536 for a full circle. Much more convenient than degrees or radians, due to the auto wraparound and ability to reinterpret it as signed 16-bit for a -180 to +180 degree value (particularly handy in AI when you're deciding whether to turn left or right). And you can still use a 32 bit int if you need to go over one rotation.

Share this post


Link to post
Share on other sites
cr88192    1570

well, a nifty thing about using 8 bits per angle is that it can allow fitting a rotation in a 24-bit value.

 

can always have something like:

32 bits: XYZ, 10 bits each (+ XZ sign)

8 bits: exponent + Y sign

24 bits: PQR rotation.

 

I actually experimented with things like this, mostly trying to fit full transforms into 64-bits, and vectors into 48 or 56 bits, but the precision wasn't really all that good (I was mostly experimenting with fitting vectors into tagged references).

 

for example (56 bit vector):

48 bits: XYZ mantissa, 15 bits each + XYZ sign

8 bits: exponent

8 bits: reserved for tag/etc

 

more effective is a 128 bit form:

96 bits: XYZ as floats

32 bits: rotation (PQR).

Share this post


Link to post
Share on other sites
cr88192    1570

I think his idea was to save space.

 

yep.

 

partly it is also that some parts of my 3D engine are currently also based around using 64-bit tagged references (IOW: dynamically-typed data), and if a value can be fit into 56 or fewer bits, then it allows it to be stored directly in the reference without having to allocate additional memory.

 

granted, the usability of something like this does depend some on having usable numerical precision.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this