-2

Fixed-point object locations allow for worlds which are much more scale-able. Using a 64-bit integer (per dimension), and 0.1 millimeter precision, a world can be created which is 100% numerically stable, and 12,000 astronomical units across.

I have been looking all over the internet, and I can't seem to find a physics engine which supports this.

Is there a 3D physics engine in existence, which uses fixed-point (i.e. Integer, hopefully int-64) values for entities' positions?

It's for a really ambitious sci-fi game I'm working on.

Kent
  • 119
  • 6
  • fixed-point object locations allow for worlds which are much more scaleable. Using a 64-bit integer (per dimension), and 0.1 milimeter precision, a world can be created which is 100% numerically stable and 12,000 astronomical units across. It's for a really ambitious sci-fi game I'm working on. The rendering engine for it is mostly complete now. – Kent Feb 14 '14 at 00:43

1 Answers1

6

I've never heard of one.

And there are reasons why nobody does it that way.

First, numerically-intense computations moved to floating point decades ago because of the amount of headache involved in keeping track of the decimal point across multiplications, divisions, and exponentiations. The moment you hit transcendental functions (sin, cos, exp), you die horribly.

Second, one light-year is about 63000 AU, so your "universe" is 1/5 of a light-year across. Given that Alpha Centauri is 4.3 light-years from Sol, your Universe is limited to one (1) solar system. AT THE MOMENT, it is summer on Pluto, meaning that it is just inside Neptune's orbit, and so the whole basic Solar system is 60 AU across (30 AU to Neptune's orbit, x 2).

You're proposing using 64 bits. It only takes about 55 bits to represent the basic Solar system, to your desired precision. Use another bit, and go out to 120 AU across.

Now, x86 extended precision (double) is 80 bits, with a sign bit, a 15-bit exponent, and a 64-bit mantissa. Your suggestion uses a 64-bit mantissa, with NO exponent. Bluntly, you aren't saving yourself any trouble by writing your own fixed-point math package.

My suggestion to you is this: Develop a prototype of your game, using plain vanilla extended precision floating point, and see whether you encounter numerical instabilities.

John R. Strohm
  • 18,043
  • 5
  • 46
  • 56
  • That is a load off my mind, thank you. Just as a side note though, my game does require all 64 bits of precision. AU is a relative term, since I will not be strict to rules of real-life physics. The space between objects (i.e. planets) will be condensed, and an entire universe, rather than solar system, will be fit into the game world. – Kent Feb 14 '14 at 02:45
  • One other thing, double precision in java, and long double in c++, are only 64 bits, implementation would require special libraries. – Kent Feb 14 '14 at 02:51
  • From http://en.wikipedia.org/wiki/Long_double: "On the x86 architecture, most C compilers implement long double as the 80-bit extended precision type supported by x86 hardware (sometimes stored as 12 or 16 bytes to maintain data structure alignment), as specified in the C99 / C11 standards (IEC 60559 floating-point arithmetic (Annex F)). An exception is Microsoft Visual C++ for x86, which makes long double a synonym for double.[2]" Continued in next comment. – John R. Strohm Feb 14 '14 at 03:13
  • Continued from previous comment: "The Intel C++ compiler on Microsoft Windows supports extended precision, but requires the /Qlong‑double switch for long double to correspond to the hardware's extended precision format.[3]" – John R. Strohm Feb 14 '14 at 03:14
  • References: [2]http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx [3]http://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os/ – John R. Strohm Feb 14 '14 at 03:16
  • The moral of the story has something to do with not using Microsoft tools for serious computing. – John R. Strohm Feb 14 '14 at 03:16
  • "With the GNU C Compiler, long double is 80-bit extended precision on x86 processors regardless of the physical storage used for the type (which can be either 96 or 128 bits)." Reference to http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html#i386-and-x86-64-Options – John R. Strohm Feb 14 '14 at 03:24
  • Perfect, now how do I build bullet for this? :P On a more serious note, answer accepted. :) – Kent Feb 14 '14 at 03:26
  • Take a look at kerbal space program - they ran into problems with Precision too (simulating a rocket in a large solar system) and solved it (even within the Unity framework). – Christian Sauer Feb 14 '14 at 08:01