Game Development Reference
What Time Is It?
The story of GPS really begins with a prize offered by the British government in 1717
for a simple way to determine your longitude. Awarded in 1773, the accepted solution
was to compare local noon to the official noon sighted at the Greenwich Observatory.
The difference between these two times would allow you to tell how far around the
world you were from the observatory. Fast-forward three centuries, and we have satel‐
lites orbiting the earth, broadcasting time-stamped messages. By calculating the differ‐
ence between the time the message was received and the time it was transmitted, we can
calculate our distance from the satellite. In both cases you need an accurate way to keep
or measure time. For sailors in the 1800s, the device was the newly invented chronom‐
eter. For us, it is the atomic clock.
Because the signals from a GPS satellite are moving at the speed of light, you need a very
accurate clock to keep track of how long it took to travel to you. For instance, if the clock
you are using to time when the signal arrives is 1 microsecond off, you will estimate a
distance over 900 miles in error. On the supply side of the signal, each satellite has an
atomic clock, and internal GPS time is accurate to about 14 nanoseconds. The problem
is that you also need a very accurate clock in the receiver, and it would be pretty hard
to fit an atomic clock into a phone economically. To get around this, the receiver must
figure out the correct current time based on the signals from the satellites.
Two-Dimensional Mathematical Treatment
This section will give you a good idea of how GPS systems determine their location.
This background will help you in many applications of geometry in games in general,
but most GPS devices do the heavy lifting and report through an API your current
latitude and longitude. Some APIs may include more information—for example, the
current iOS API, called Core Location, gives the current latitude and longitude, the
direction of travel, the distance traveled, and the distance in meters to a given coordinate.
It also gives an estimate for the error associated with its position fix in meters.
One way to get your position via the kind of information that GPS provides is a technique
called trilateration . We are going to give this problem a mathematical treatment in two
dimensions. You could extend this to three dimensions by using spheres instead of
To begin, we can list our unknowns: our x coordinate and y coordinate in space, and
the error in our receiver's clock (or bias ), b . In a two-dimensional plane, trilateration
among three circles gives you an exact position; in three-dimensional space, four
spheres are required to determine all three special coordinates. Note that if we included
an assumption about being on the surface of some geometric shape, such as the earth,