.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Attempting to create float free engine
Old
  (#1)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Attempting to create float free engine - 29-12-2005

Yes, I know it is difficult. I have created a float-implementation independant way of converting floats to 16:16 integers. It is not endian independant, though. Of course it doesn't matter that much, because floats are always stored the same way IIRC except on a VAX or ALPHA or something.

Anyway, I am going to be generating tables for SIN and COS and am planning to use a base two system instead of radians or degrees. How much precision will I need? I am planning to make it 4096 ints long. This way I won't have to perform a modulus operation; I can use bit manipulation instead. Is this enough?

My only other problem is square roots, that will be a pain in the ass.

If you didn't get what I meant by precision, let me elaborate. I plan to make 0 degrees 0 and 360 degrees 4096. 4096 won't exist in the table because it is redundant. Is 4096 enough, or should I go up?


sfx1999.postcount++
  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#2)
DrEvil
Member
 
DrEvil's Avatar
 
Status: Offline
Posts: 142
Join Date: Jan 2004
Location: Los Angeles, CA
Default Re: Attempting to create float free engine - 30-12-2005

Why are you doing this? Modern hardware is very good at floating point math. I can't see any reason you'd want to do this.


Omni-bot AI framework
http://www.omni-bot.com

Foxbot - for Team Fortress Classic
http://www.foxbot.net


  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#3)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Attempting to create float free engine - 30-12-2005

I would say so too. unless you are working on a FLPT unit for some open source CPU

for that lookup table ... calculating the error is depending on how you calculate the values. do you just take the nearest neighbour, do you use linear interpolation, or higher order polynoms. you might wanna look up the error formula under "remainder lagrange interpolation"


  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#4)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Attempting to create float free engine - 01-01-2006

The main reason I want to do this is due to PDAs not having float support. It is kind of a proof of concept thing. Unfortunately, I don't know if they have hardware divide either, so that could hurt.


sfx1999.postcount++
  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#5)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Attempting to create float free engine - 01-01-2006

PHP Code:
// faster method to calculate 1.0/sqrt(f)
inline float InvSqrt(float f)
{
   
float half 0.5f f;

   
long lBits = *(long *)&f// evil floating point bit level hacking
   
lBits 0x5f3759df - (lBits >> 1); // WTF?
   
= *(float *)&lBits;
   
*= 1.5f half f// 1st iteration
//   f *= 1.5f - half * f * f; // 2nd iteration, this can be removed

   
return f;

also see the gcc and/or glibc source code
  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#6)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Attempting to create float free engine - 01-01-2006

but that only works for 32bit float of this one very standard, dunno what sfx wants to implement ... and there should be another way to do a divide but dividing by it's root, doesnt it ?


about your precision : you just need to know your wanted precision and know the interpolation method ( I guess just linear interpolation for the sake of simplicity for now ) and then you can calculate the maximum distance between two entries for this point using this lagrange remainder.


  
Reply With Quote
Re: Attempting to create float free engine
Old
  (#7)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Attempting to create float free engine - 02-01-2006

My precision ony can go to 1/32768, unfortunately.

Let me try to elaborate, only using 8 bits:

sign bit, 4, 2, 1, 1/2, 1/4, 1/8, 1/16
00011000

I am doing this with 32 bits, though. One thing, after you multiply, you will need to bitshift back, because the answer will be too large. You also need to shift after a divide, or else the answer will be to small. Addition and subtraction can be done normally. Doom uses this method.


sfx1999.postcount++
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com