I need some help. I have cross posted to omnimaga as well. I need to do a 3-variable distance formula, where all variables are 24-bits large.

√ ( (xxx2-xxx1)^2 + (yyy2-yyy1)^2 + (zzz2-zzz1)^2 )
Why ever do you need all that precision? When you square 24-bit variables, they could be up to 48 bits, then you'll be taking the square root of a 48-bit variable. That seems extreme to me. Surely you could instead square 16 (or Cool bit variables and then you'd have the square root of a 32 (or 16) bit variable.
Because the distance coordinates are three bytes large, Kerm.

The sector is one byte large, and the coordinates are two bytes large. That's three bytes. Do I need 3 bytes for a virtual "space" or will a 2-byte limited playing area be good enough?
ACagliano wrote:
Because the distance coordinates are three bytes large, Kerm.

The sector is one byte large, and the coordinates are two bytes large. That's three bytes. Do I need 3 bytes for a virtual "space" or will a 2-byte limited playing area be good enough?


Sector, meaning which quadrant? in that case, 24 multiplication isn't needed; you'll just be working with the 16 bits used for the actual coordinates.
Yes. Quadrant. Sector. Same idea.
ACagliano wrote:
Yes. Quadrant. Sector. Same idea.


Well, if you're in 3D space, you only have 8 Quadrants to work with... why use a whole byte to save that? I would compress it to 3 bits and use 13 other bits for coordinates. In fact, why use an explicit Quadrant field anyways? Can't you just quickly derive that from the current coordinates instead of having to carry it around in the coordinate structure?
Well, no. I was going to actually make the quadrant the highest byte in a 3-byte structure.

PositionData:
.db SectorX,PositionX,PositionX
(where PositionX maxes at 65536 and SectorX maxes at 255)
and so on for Y and Z.
I absolutely second Ashbad's ideas to make the location be 16 bits for each axis; since you have three axes, only the top bit of each coordinate is necessary to define quadrant (2*2*2 = 8). That leaves you with a whole 15 bits for position, and believe you me when I tell you that a calculator gamer is not going to want to trek across 32K pixels *2 quadrants = 64K pixels (that's 683 screen widths or 1024 screen heights, for what it's worth).
Ok, well, I can just scrap the sector all together and just use a two-byte position.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement