Skip to content

Two-Dimensional Kinematics

The basic idea to extending the study of kinematics to two dimensions is surprisingly easy: horizontal and vertical motions are independent. Or, in other words, each motion behaves as if the other motion were not present. The TL:DR version of this tutorial is: Everything works just as it used to in one dimension, including the symplectic integration.

In what follows, we will give a geometrical explanation as to how two-dimensional motion works, the internal computations, using symplectic integration, do not change, however.

To code information about movement in more than one direction, vectors are used. In this tutorial, all vectors are elements of the standard two-dimensional vectors space , with the standard basis and , as well as equipped with the standard scalar product. An element can thus be represented by the standard basis as follows:

Let be a vector. By abuse of language, we will write , if it is clear, from the context, that we are only interested in the magnitude of the force, and not in its direction or sens.

Please note that, unlike in one dimension, the graphs of the position and velocity functions are no longer subsets of . In the two-dimensional case, those functions look a bit differently. Let and two functions defining the position of an object on the , resp. the -axis, with respect to time, then the two-dimensional position function can be defined as , . Let further and be two functions defining the velocity of an object when moving in the , resp. the -direction, then the function describing the velocity of the object can be defined as , The graphs of and are thus subsets of .

Position and Displacement

The position of an object is coded in a two-dimensional vector , where denote the objects position in the -axis and -axis respectively. The following figure shows the vector with coordinates , which means units to the right (the direction of ) and units up (the direction of ):

A two-dimensional vector in the standard euclidean plane

Please note that in the standard plane, vectors correspond to the points they are pointing to. The position of the object is equal to the position of the point A in the figure above.

The two-dimensional displacement of an object can then easily be computed as where denotes the position of the object at a time and the position of the object at a time .

The displacement vector can be considered the vector joining two points in the plane and its coordinates are the difference of the coordinates of the end point and the starting point : As an example, let the starting point be and the end point be , then the displacement vector is which means a negative displacement in the direction of the -axis and a positive displacement in the direction of the -axis.

The displacement vector can be seen as the vector joining two "points" in the plane

Velocity and Speed

As in the one-dimensional case, the average velocity vector is defined as the displacement over time: .

As an example, assume that a dog is observed initially at the position and three seconds later at the position , then the average velocity of the dog during that time was: which means that its average velocity in the -direction was and its average velocity in the -direction was .

Note that as stated in the introduction, both average velocities are completely independent of each other, or, in other words, we would have got the same result, had we computed them separately one after the other. Try it out if you don’t believe me.

The instantaneous velocity is also defined, analogously to the situation in one dimension, by using the derivative: Geometrically, the average velocity points in the same direction as the displacement vector, while the instantaneous velocity is a vector tangent to the curve of the motion.

To actually compute the speed of an object, the norm of the velocity vector must be computed using the scalar product: .

Please note that, as before, the vector of the instantaneous velocity shows the direction an object is moving in. The * direction* , expressed as an angle relative to the -axis, can be computed using the arctangent function: .

As an example, imagine a trout swimming around with a velocity of , then the speed of the trout is and the direction of movement is , which means the velocity vector creates an angle of degrees with respect to the -axis, i.e. the trout was swimming to the northeast.

It might also be interesting to note that when one is only interested in comparing the speed of two objects, it is not necessary to compute the square root. Let and be the speed of two objects, then , as the square root function is continuous.

While computing the square root is no longer as costly as a few years ago, saving some computational time (for free) is always a good thing!

Acceleration

The average acceleration vector is the change in the velocity vector over time: Note that an object can accelerate even if its speed is constant, just imagine a car driving in a circle with constant speed:

A car driving in a circle with constant speed

In the figure above, the car drives at a constant speed, but the velocity changes as it’s the direction of motion keeps changing. Which means that the car accelerates without changing its speed.

Also note that the direction of the acceleration need not point in the direction of motion, it won’t do so in most cases.

The instantaneous accelerations is defined by using the derivative: As an example, imagine a car travelling northwest (at an angle of ) at . Eight seconds later, it has rounded a corner, and is now speeding south at . To find the average acceleration of the car during those eight seconds, we must first compute the initial, , and final, , velocities: and The change in velocity is thus . Knowing the change in velocity, it is now possible to compute the average acceleration: . The average acceleration was thus approximately and the angle of the direction of the average acceleration, regarding the -axis, was , i.e. the direction of the average acceleration was to the southeast.


I created a primitive Geogebra applet to let you toy around with a particle, called Cosmo, moving around a winding path. Use the slider to move Cosmo around, and see how the velocity and acceleration vectors, computed using the derivative, change. You can use the mousewheel to zoom in and out, and holding the left mouse button allows you to move the viewport. Alternatively, click here, to open the applet in GeoGebra.



Implementation

As stated in the introduction, nothing really changes when it comes to approximating a discrete solution to the equations of motion. Recall that and are the two functions giving the position and the velocity of an object at any moment in time. Let further and be the derivative and second derivative of , then the equation of motion looks the same as in the previous tutorial: , which once again translate to the same system of differential equations:

The C++-code for the symplectic integrator thus remains impertinently easy:

void Kinematics::semiImplicitEuler(mathematics::Vector2F& pos, mathematics::Vector2F& vel, const mathematics::Vector2F acc, const double dt)
{
vel += acc * dt;
pos += vel * dt;
}

As a little demo, I started an alien invasion:

util::Expected<void> PlayState::update(const double deltaTime)
{
if (isPaused)
return { };
// get meters per pixel
const float mpp = physics::Kinematics::metersPerPixel;
// update position based on symplectic integration of the equations of motion
for (unsigned int i = 0; i < centers.size(); i++)
{
// symplectic integrator: semi-implicit Euler
physics::Kinematics::semiImplicitEuler(centerVecs[i], velocities[i], accelerations[i], deltaTime);
// wrap screen
unsigned int width = dxApp.getGraphicsComponent().getCurrentWidth();
unsigned int height = dxApp.getGraphicsComponent().getCurrentHeight();
if (centerVecs[i].x > width)
{
centerVecs[i].x = width;
accelerations[i].x = -accelerations[i].x;
velocities[i].x = -velocities[i].x;
}
if (centerVecs[i].x < 0)
{
centerVecs[i].x = 0.0f;
accelerations[i].x = -accelerations[i].x;
velocities[i].x = -velocities[i].x;
}
if (centerVecs[i].y < 0)
{
centerVecs[i].y = 0.0f;
accelerations[i].y = -accelerations[i].y;
velocities[i].y = -velocities[i].y;
}
if (centerVecs[i].y > height)
{
centerVecs[i].y = height;
accelerations[i].y = -accelerations[i].y;
velocities[i].y = -velocities[i].y;
}
}
// return success
return { };
}

Alien Invasion

You can download the source code from here.


So far the symplecticness of the semi-implicit Euler method has really worked out quite well for us. Handling motion, in any dimensions, is totally easy!

In the next tutorial, we will learn how to simulate projectile motion! Fire in the hole!

References

  • Geogebra
  • Physics, by James S. Walker
  • Tricks of the Windows Programming Gurus, by A. LaMothe
  • Wikipedia