# Applications of calculus?

I understand that basic calculus is applicable to game development, particularly physics. Problem is, I'm not entirely sure how. So, what can I use it for? I'm most concerned about what's on the AP tests, as I hear I won't need much more than that;

AP Calculus - AB

I'm particularly interested in hearing examples in terms of gameplay elements.

• If you're not keen on inventing new methods/algorithms, advanced calculus is not that important. But if you go for understanding/applying/improving Physics algorithms, Calculus and Discrete Differential Geometry are a must. A Physics engine is 99% a gameplay factor. 1% perhaps for less interactive elements.. Again, go for research and deep understanding of what's behind the apparently simple formulae, and you'll want to understand advanced Calculus thoroughly. Also, it doesn't hurt to play with generalizations of simple tools: derivatives, integrals, forms, metrics, etc. Apr 18, 2012 at 11:32
• How might I do that? Apr 18, 2012 at 15:44
• For gameplay elements, you'll need to master the cross-multiplication. That's something you'll use everyday ;) A bit of linear algebra and trigonometry helps. But you need to study all this advanced math because you'll use tools that are based on it. Apr 18, 2012 at 19:56
• So it's like learning how to use a hammer so I can operate a nailgun? Apr 18, 2012 at 21:58
• Nope, but you're close! It's like learning how compressed air gizmos are designed to make your custom bad a** nail-gun. Trust me, if you like mathematical tools just a bit, you won't regret understanding those concepts. you could read some books: geometric algebra, Mathematics for Game Developers, Physics for Game Programmers, 3D Math Primer for Graphics and Game Development. Amazon is full of them, must be a reason why people write them Apr 19, 2012 at 9:40

In a game, one of the most basic systems you may come across is Euler's Method. It's a good way of approximating the result of an integration over time. Here is a simple example:

Velocity = Velocity + (Acceleration * ElapsedTimeSinceLastUpdate);
Position = Position + (Velocity * ElapsedTimeSinceLastUpdate);


Bare in mind that integrating a function of acceleration gives you the function of velocity and integrating the function of velocity gives you the function of position.

This is useful for doing many actions over a period of time.

One of the more common ways I have used calculus however, is simply to prove that an equation I have come up with will work as I intend before I go to the trouble of implementing it.

For example, I once made an equation of velocity which would change an objects orientation over a fixed time period until it had moved to a new desired orientation (it was a bell curve so it would ease in and out of the animation).

By integrating the equation over the fixed period I could show that it would always result in the total change in angle I required. This meant that, with some simple calculus on paper, I could be sure it was worth implementing before I went ahead. It also meant that I had an equation of position which could simply be queried relative to the time since the start of the animation so I wouldn't have to constantly add the velocity onto the position.

• So, if I understand, you whipped up a formula that modelled something rotating. What exactly did integrating it provide again? The degree the object was rotated (with 0 at the right)? Apr 18, 2012 at 15:43
• Well I knew what I wanted the velocity graph to look like which I could then create the function for, but integrating gave me a different equation which allowed me to get the current orientation at deltaTime rather than it's velocity (which I would then have to use Euler's method to get the position for). Also, since it gave me the position at a given point, I could check that plugging in my values resulted in the orientation being correct at the end of the time period for the animation, thus I could check the function was correct before implementing it. Apr 18, 2012 at 15:58
• So if I wanted something to move at constant speed, would velocity just be a horizontal line? And then have position be linear? In a demo I'm writing, I have an object moving on a diagonal line back and forth, reversing direction at two particular points. Rather than throwing in some conditionals, I can just model that with an equation and shrink my code? Apr 18, 2012 at 16:08
• Oh, and I assume the independent variable would be the time elapsed. Apr 18, 2012 at 16:17
• The independent variable is time elapsed - since the start of the animation though. As for using it to move at a constant speed up and down a line, it's probably not worth it. If, however, you wanted to make that speed vary across the line and you could map this to a wave form, it may help you. To use a similar method to mine you would have to make it one dimensional so your equation would give you the position of the object along the line rather than using seperate functions for X and Y over time. Apr 18, 2012 at 16:48

Also, 3d programming is relies heavily on multivariable calc and linear algebra. And many complex simulations like fluids use calculus.

• How important is multivariable calculus, exactly? Important enough to take instead of numerical analysis? Apr 18, 2012 at 15:38
• Also, what about differential equations? Apr 18, 2012 at 15:46
• Force as a gradient OR variational derivative of a scalar field, gradient descent, Jacobians.. oh my, these things come useful when doing kinematics, soft/elastic bodies, or heck, even shooting some particles to make firework explosions. But that's mostly Physics (for gaming). Computer graphics modeling makes use of such concepts as well, but you do have 3dsMax, Maya, Blender that takes care of that. Then again, you do have Physics Engines.. But you can't conceive/understand algorithms without those notions. So if you learn Algebra 101 and Calculus 101, it's enough for a plain game developer. Apr 19, 2012 at 9:45
• Also, think of something you'd like to see in a game, and we'll tell you what parts of Advanced Mathematics you might need. Again, sorry, it's just too hard to enumerate why and what for you need those things, that's a subject of an entire book collection. And there are books on CAD CG, Game Physics, Game Maths, Real Time Physics Based Rendering..etc.. they all require you to understand the basics and to have a basic understanding of the advanced concepts, to say the least. Apr 19, 2012 at 9:48
• What would you consider a good general advanced math toolkit (sans linear algebra and single-variable calculus)? I'm mostly concerned with things like motion (like enemy patterns for a shmup) and non-linear transformations (like stretching) right now. I'd also like to get a sense of how long it would take to learn some of these concepts, if I could forgo a formal class and Wikipedia some of it as necessary. Apr 20, 2012 at 13:24