Game-physics for beginners, part i: Forces and accelerations

March 7, 2010

game-physics-logo_rotl_smallThis first tutorial describes the basic relationship between force and acceleration that everybody who seriously wants to get a start on game-physics should be aware of. It then goes on to introduce a common approach to modelling simple motion.

Forces and accelerations

As one probably recalls from school, Newton’s 2nd Law states:

F = m * a       (N2)

Or in words: Force F equals mass m times acceleration a. A direct consequence of (N2) is the statement that:

Forces give rise to accelerations (N2)

Above is a statement that people did not always fully understand (in fact, for a long time it was believed that forces would cause velocities – they do not!).

The next important point is what is stated by Newton’s 1st Law:

A body remains at rest or at steady speed in a straight line
until acted upon by a force
(N1).

Example: Throwing a ball in two dimensions

So what do above definitions mean for modelling physics? Well, lets take an example: Imagine throwing a ball. You wind up, and once you let go off it, the ball starts to move. But why does it move?

The ball moves because of the force you applied (the throw) which gave rise to an acceleration (N2). Now in free space, the ball would keep moving forever (N1)!

However, that is not what we observe on Earth! Instead, we are used to the ball moving slower and slower and eventually coming to rest on the ground some dozen meters away from our position.

The situation could look a bit like in the following screenshot of a Java-Applet:

throwing_a_ballScreenshot of Java-Applet from Easy Java Simulations Website
(click on image to go to website)

So the ball does – in contradiction to what has been stated above – not all keep moving forever! But how come?

Well, on Earth – in contradiction to free space – there are various external effects that slow the ball down or alter its direction, e.g. air resistance (friction) or gravity.

What’s important here is the following: The mentioned effects that slow the ball down are nothing more than forces acting on the ball. They cause changes in the acceleration of the ball, so that it moves slower and slower and so on.

Hence for modelling physics, if we want to describe the motion of the ball, we definitely have to take into account the accelerations caused by the various external forces acting on the ball! This is a crucial point for our models, so keep it in mind!

Modelling one-dimensional motion of a ball

There are various approaches to modelling the motion of simple objects like balls. The method that follows is a commonly used one. However, we are not going to use it anywhere apart from this short introduction. The method we will use instead is based on acceleration (as described above) and is started to develop from part ii onwards.

Example 1: How you do not want to do it

Imagine you just want a ball  that moves from the left to the right of the screen in one dimension (i.e. horizontal motion in a straight line at uniform speed in free space). Then it would be enough to increase its position by a small amount Δpos_x =: stepsize each frame. That is:

ball.pos_x = ball.pos_x + stepsize;

Here’s what it could look like: Particle moving from left to right in free space.

This is a nice and simple approach to animation that works in situations where physics does not play a relevant role.

But once (multiple) forces have to be considered accurately, it will lead to various problems. Hence this is not what we want to do here! Instead, we want to do it the right way! So let us start with a more useful method right from the beginning in part ii.

Summary part i

In this part of the tutorial:

  • We reviewed the important relationship between force and acceleration.
  • We started to think about modelling the motion of an object in one dimension.
  • We stated that a sensible model takes more than just increasing an object’s position by some constant increment every frame.
  • We realised that we have to work on a way to describe the motion of an object by using its acceleration, thereby taking into account the forces that act upon it.

Please feel free to comment.

One Response to “Game-physics for beginners, part i: Forces and accelerations”

  1. Ben said

    Hey Ben,
    hope you get back to writing your physics tutorials. I myself am a hobby physics developer, and always love to read tutorial/blogs on the subject.

    Thanx

    B.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.