Global Positioning System Reference
In-Depth Information
Figure6.1. Motion can be calculated with geometric rules instead of physical
formulas.
the previous vector in the same direction and same length and draw a
small black circle. The corners of the four squares around this circle define
nine possible destination points (black circles). Pick one of these in the
appropriate direction to match your race track and draw the next vector
for your next move.
For a simple game, nine possible destination points will be adequate.
For a real-world simulation, the destination square is a characteristic ellipse
changing its shape according to the car's parameters. If the car is going
full speed only the back part of the ellipse represent the destination area
and the ellipse is very thin. The car can only make slight turns at high
speeds. When the car reduces speed the ellipse gets wider.
The upper part of the figure (thick arrows) demonstrates the rules for
moving your car. The thick dashed lines show how you can actually analyze
typical racing maneuvers.
Let's say both cars have the same top speed entering from the right side.
The gray car is keeping up its speed to defend the inside of the next curve.
The white car realizes that it can't pass the opponent and reduces speed.
Due to mass and speed (inertia), the gray car is carried away from its
ideal course. Due to a lower speed, the white car can pass its opponent.
Note that the gray car can get the lead back, if the next turn is sharp to
the right.
This is only one way to provide the two parameters speed and direction
needed for the move method; you should try to implement your own. As
 
Search WWH ::




Custom Search