Game Development Reference
In-Depth Information
barrel also spin and are affected by this Magnus force. There have even been sailboats
built with tall, vertical, rotating cylindrical “sails” that use the Magnus force for pro‐
pulsion. We've also seen technical articles describing a propeller with spinning cylin‐
To further illustrate the Magnus effect, we've prepared a simple example program that
simulates a ball being thrown with varying amounts of backspin (or topspin). This
example is based on the cannon example, so here again, the code should look familiar
to you. In this example we've neglected drag, so the only forces that the ball will see are
due to gravity and the Magnus effect. We did this to isolate the lift-generating effect of
spin and to keep the equations of motion clearer.
Since most of the code for this example is identical, or very similar, to the previous
cannon examples, we won't repeat it here. We will, however, show you the global vari‐
ables used in this simulation along with a revised DoSimulation function that takes care
of the equations of motion:
//----------------------------------------------------------------------------//
// Global variables required for this simulation
//----------------------------------------------------------------------------//
TVector V1; // Initial velocity (given), m/s
TVector V2; // Velocity vector at time t, m/s
double m; // Projectile mass (given), kg
TVector s1; // Initial position (given), m
TVector s2; // The projectile's position (displacement) vector, m
double time; // The time from the instant the projectile
// is launched, s
double tInc; // The time increment to use when stepping
// through the simulation, s
double g; // acceleration due to gravity (given), m/s^2
double spin; // spin in rpm (given)
double omega; // spin in radians per second
#define PI 3.14159f
#define RHO 1.225f // kg/m^3
//----------------------------------------------------------------------------//
int DoSimulation(void)
//----------------------------------------------------------------------------//
{