Leading the way to the Future
 08 Dec 2011 04:07:27 pm by ACagliano Distance Formula, 3D, 24-bit Quote 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 )
 08 Dec 2011 07:02:29 pm by KermMartian Quote 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 bit variables and then you'd have the square root of a 32 (or 16) bit variable.
 08 Dec 2011 07:10:50 pm by ACagliano Quote 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.
 08 Dec 2011 09:12:20 pm by ACagliano Quote 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?
 09 Dec 2011 07:24:17 am by ACagliano Quote 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.
 09 Dec 2011 10:46:13 am by KermMartian Quote 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).
 09 Dec 2011 09:37:29 pm by ACagliano Quote Ok, well, I can just scrap the sector all together and just use a two-byte position.