Don't have an account? Register now to chat, post, use our tools, and much more.
Online Users
There are 129 users online: 10 members, 98 guests and 21 bots.
Members: ACagliano, assemblybandit, FrozenFire49, majolx, tonayyy23, tr1p1ea, umer936, zeldaking.
Bots: VoilaBot (4), Spinn3r (1), MSN/Bing (1), Magpie Crawler (3), VoilaBot (9), Googlebot (3).
SAX
Author Message
ACagliano

Super-Expert

Joined: 08 Feb 2010
Posts: 994

 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%
KermMartian

Joined: 14 Mar 2005
Posts: 57341

 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._________________
ACagliano

Super-Expert

Joined: 08 Feb 2010
Posts: 994

 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%

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
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.
_________________
IT IS NOTHING BUT BLACK METAL NOVEMBER

YOU HAVE NO EXCUSES
ACagliano

Super-Expert

Joined: 08 Feb 2010
Posts: 994

 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%

Such ashy church, much Burzum

Joined: 01 Dec 2010
Posts: 2453
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?
_________________
IT IS NOTHING BUT BLACK METAL NOVEMBER

YOU HAVE NO EXCUSES
ACagliano

Super-Expert

Joined: 08 Feb 2010
Posts: 994

 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%
KermMartian

Joined: 14 Mar 2005
Posts: 57341

 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)._________________
ACagliano

Super-Expert

Joined: 08 Feb 2010
Posts: 994

 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%
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
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.

»
 Page 1 of 1 » All times are GMT - 5 Hours

 Jump to: Select a forum Announcements----------------Cemetech AnnouncementsCemetech LabsContests General Discussion----------------Technology & Calculator Open Topic-- Electronics/Hardware Development-- Calculator HardwareYour ProjectsGeneral Open Topic-- Politics & Rants-- Reviews-- Humour/Jokes Cemetech's Projects----------------Doors CS and Doors CSESourceCoderMember Features-- TI-Freak8x-- Merthsoft-- GrammerOther & Upcoming Projects-- The BASIC Elite-- mobileTunes-- CALCnet 2.2-- SuggestionsProgramming the TI-83 Plus/TI-84 PlusUsing the TI-83 Plus/TI-84 PlusWebsite Programming & Design----------------General Programmingz80 AssemblyTI-BASICCasio Prizm/FX Development & ProgrammingWebsite Markup & ScriptingGraphics1337 Programming Tips Building with Blocks----------------FreeBuild, LEGO, and Minecraft-- FreeBuild General-- Suggestions & Troubleshooting-- Content & Gallery-- Servers & Activities
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.035730 seconds.