Game Design, Programming and running a one-man games business…

Pay attention to trigonometry

Do you want to program computer games?

Do you understand trigonometry?

If not, you need to. I (rather famously) do 2D rather than 3D games. But that doesn’t mean I don’t use maths. I use a lot of maths, every day. The one area I use all the time, is trigonometry. A sine wave is a beuatiful thing. A curve that simple (in maths terms) is just incredibly elegant and finds its way into everything. It’s amazing how often you need to express something in a game in terms of a nice smooth curve. Knowing the (very simple) maths behind a sine wave, and similar functions is just vital if you want to code games.

Geometry and trig is taught really badly at school. Do you know the ‘real world’ examples used to illustrate the usefulness of this stuff at my school? I remember it to this day, “imagine you work in a factory where you need to calculate the volume of a can of baked beans”. How about this: “imagine you have the most tedious job in human history”.

Now imagine how games coders use it.

“Imagine you are making a smooth oscillation of a spaceship laser beam as it sweeps across space attempting to lock onto an enemy fighter”

“Imagine a spaceship has exploded and you need a smooth way to fade in and out the brightness of a shockwave which occurs as the ship blasts into pieces.”

If you are still at school, pay attention during maths. Trig used to be pretty useless (although I even used it as a boatbuilder) for most jobs. For the really cool jobs involving things exploding, it can be bloody useful.

Don’t underestimate how well you need to know this stuff. I got an A in my maths O level a year early, I got an A in stats a year later. I was top of the whole year in maths. I got 100% on my maths O level mock. And in programming terms, I SUCK at maths. I used to ask other coders for help with maths stuff. Being the absolute best at maths might not get you the girls when you are sixteen, but it really matters big time later on. Study the maths.


9 thoughts on Pay attention to trigonometry

  1. Totally agree with this post. Even for something as simple as figuring out what direction to move when activating a thruster at the rear of a ship (i.e. asteroids) you need a basic understanding of trigonometry. As professed math whiz do you have any recommendations for resources for those of us who are a little weaker in the subject?

  2. I was the same at maths, 100% all the way until one day I got 96% and was mortified. Then it went downhill but I blame it all on girls.

    Good old SOHCAHTOA use it a lot.

  3. Good programmer have to quickly know the right “math” solution of the problem. If he can’t do this quickly (or at all) that programmer sux, even he knows 20 programming languages well…

    Sorry for my English.

  4. Good post cliffski. God knows how kids are taught maths nowadays. I often think they should use games more to get kids into this stuff (i’m sure some teachers must?). Not as some gimmick, maths is required to solve the problems!

    I did well at uni in maths, but I still fight a bit with matricies and coordinate systems. And, even with trig I sometimes get bugs in certain quadrants cos I’ve assumed something wrong…

    Anyway, Some Old Hippy Could Arm Himself To Overthrow America (thats how i remember it!).

  5. I worked with vectors before I heard about them in school. So now I love vectors, dot products, cross products – they are so much fun! :)

    But I was always afraid of matrices, 4×4, wtf? But I had to use them later, and realised that they are just as simple as vectors. Now I love them too, because they are so useful! ;)

    It’s a pity that they never tell us in schools, how great cos and sin can be (but it willl change soon).

  6. This is the problem with trig for me. I got an A at maths GCSE but gave it up for A level as I didn’t like it much. Things like trig never were taught with any context.

Comments are currently closed.