Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 144 users online: 2 members, 103 guests and 39 bots. Members: JamesV, legodude. Bots: VoilaBot (4), Magpie Crawler (5), VoilaBot (10), Googlebot (20).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
ACagliano
Super-Expert

Joined: 08 Feb 2010 Posts: 930
|
Posted: 08 Dec 2011 04:07:27 pm Post subject: Distance Formula, 3D, 24-bit |
|
|
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 ) _________________ -ACagliano
Current Projects
Legend of Zelda. "Ganon's Rage"
51% |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55886 Location: Earth, Sol, Milky Way
|
Posted: 08 Dec 2011 07:02:29 pm Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
|
ACagliano
Super-Expert

Joined: 08 Feb 2010 Posts: 930
|
Posted: 08 Dec 2011 07:10:50 pm Post subject: |
|
|
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
Current Projects
Legend of Zelda. "Ganon's Rage"
51% |
|
| Back to top |
|
|
Ashbad

I am governor Jerry Brown

Joined: 01 Dec 2010 Posts: 2423 Location: There lived a certain man in Russia long ago
|
Posted: 08 Dec 2011 07:21:35 pm Post subject: |
|
|
| 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. _________________ -Ashbad |
|
| Back to top |
|
|
ACagliano
Super-Expert

Joined: 08 Feb 2010 Posts: 930
|
Posted: 08 Dec 2011 09:12:20 pm Post subject: |
|
|
Yes. Quadrant. Sector. Same idea. _________________ -ACagliano
Current Projects
Legend of Zelda. "Ganon's Rage"
51% |
|
| Back to top |
|
|
Ashbad

I am governor Jerry Brown

Joined: 01 Dec 2010 Posts: 2423 Location: There lived a certain man in Russia long ago
|
Posted: 08 Dec 2011 09:16:53 pm Post subject: |
|
|
| 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? _________________ -Ashbad |
|
| Back to top |
|
|
ACagliano
Super-Expert

Joined: 08 Feb 2010 Posts: 930
|
Posted: 09 Dec 2011 07:24:17 am Post subject: |
|
|
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. _________________ -ACagliano
Current Projects
Legend of Zelda. "Ganon's Rage"
51% |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55886 Location: Earth, Sol, Milky Way
|
Posted: 09 Dec 2011 10:46:13 am Post subject: |
|
|
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). _________________
 |
|
| Back to top |
|
|
ACagliano
Super-Expert

Joined: 08 Feb 2010 Posts: 930
|
Posted: 09 Dec 2011 09:37:29 pm Post subject: |
|
|
Ok, well, I can just scrap the sector all together and just use a two-byte position. _________________ -ACagliano
Current Projects
Legend of Zelda. "Ganon's Rage"
51% |
|
| Back to top |
|
|
|
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
|
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
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.027859 seconds.
|