Game Development Reference
In-Depth Information
If there are a finite amount of discrete things in the universe, as currently
appears to be the case, then it follows that we can only count to a certain
fixed number, and thereafter we run out of things to count on—not only do
we run out of dead sheep, but toasters, mechanics, and telephone sanitizers,
too. It follows that we can describe the universe using only discrete mathe-
matics, and only requiring the use of a finite subset of the natural numbers
at that (large, yes, but finite). Somewhere, someplace there may be an
alien civilization with a level of technology exceeding ours who have never
heard of continuous mathematics, the fundamental theorem of calculus, or
even the concept of infinity; even if we persist, they will firmly but politely
insist on having no truck with π, being perfectly happy to build toasters,
bridges, skyscrapers, mass transit, and starships using 3.14159 (or perhaps
3.1415926535897932384626433832795 if they are fastidious) instead.
So why do we use continuous mathematics? Because it is a useful tool
that lets us do engineering. But the real world is, despite the cognitive
dissonance involved in using the term “real,” discrete. How does that affect
you, the designer of a 3D computer-generated virtual reality? The computer
is, by its very nature, discrete and finite, and you are more likely to run into
the consequences of the discreteness and finiteness during its creation than
you are likely to in the real world. C++ gives you a variety of different forms
of number that you can use for counting or measuring in your virtual world.
These are the short , the int , the float and the double , which can be
described as follows (assuming current PC technology). The short is a 16-
bit integer that can store 65,536 different values, which means that “many
sheep” for a 16-bit computer is 65,537. This sounds like a lot of sheep,
but it isn't adequate for measuring distances inside any reasonable kind of
virtual reality that take people more than a few minutes to explore. The
int is a 32-bit integer that can store up to 4,294,967,296 different values,
which is probably enough for your purposes. The float is a 32-bit value
that can store a subset of the rationals (slightly fewer than 4,294,967,296 of
them, the details not being important here). The double is similar, using
64 bits instead of 32.
The bottom line in choosing to count and measure in your virtual world
using int s, float s, or double s is not, as some misguided people would have
it, a matter of choosing between discrete short s and int s versus continuous
float s and double s; it is more a matter of precision. They are all discrete
in the end. Older topics on computer graphics will advise you to use integers
because floating-point hardware is slower than integer hardware, but this
is no longer the case. In fact, the introduction of dedicated floating point
vector processors has made floating-point arithmetic faster than integer in
many common cases. So which should you choose? At this point, it is
probably best to introduce you to the first law of computer graphics and
leave you to think about it.
Search WWH ::




Custom Search