When I was designing Blindfold Racer several years ago, I had to consider how to lay out the road. Blindfold Racer started as a STEM after-school club for 5th and 6th graders. Together we designed the game and then I programmed it at home.
I thought about how the students were laying out the road track, and I needed an easy way to convert that into a virtual track in the game. I also thought that in a future version of the game, we may want game players to create their own tracks and then drive on it.
I found a sample iPhone tutorial lets you draw on the screen (with your finger), and then tells you the points on the line. Using that program, I could draw the “center line” of the track, and I would simply have to write a new program to compute the left and right edges of the track (based on the width of the track). Easy? No!
It took about two weeks of relearning my trigonometry from high school to figure out how to do that – for example, how to rotate a square:
You need to know which direction the car is moving to understand which is the left fence and which is the right fence. For a straight track, it’s easy. For a track in the shape of a vertical “S” or a horizontal “S”, it becomes more difficult.
Essentially, I have to determine the bounding square of the track for every point on the “center line”:
and from that compute the left and right sides of the track.
Now, when my daughter asks me, “what good is trigonometry – no one really needs it when they are grown up“, I know what to say.