Game Development Reference
In-Depth Information
In Equation (5.31), r x , r y , and r z are unit vectors that define the axis of rotation.
Equation (5.31) is the general equation for the Cartesian components of Magnus force. The
equations simplify considerably if the axis of rotation is parallel to one of the coordinate axes.
For a sphere with an axis of rotation parallel to the y-axis, r x = 0 , r y = 1 , and r z = 0 , the x-, y-, and
z-components of Magnus force become the following:
v
F
=−
z
r F
(5.32a)
Mx
y
M
v
F
=
0
(5.32b)
My
v
x
F
=
r F
(5.32c)
Mz
y
M
v
At first the Magnus force equations shown in Equation (5.32) may look a bit strange because
the x-component of force is a function of the z-component of velocity, but keep in mind that
Magnus force acts perpendicular to velocity vector. The y-component of force is zero in
Equation (5.32b) because we assumed the axis of rotation was parallel to the y-axis and the
direction of Magnus force is always perpendicular to the spin axis.
Now that we have expressions for the x-, y-, and z-components of Magnus force, spin effects
can be incorporated into our projectile trajectory code. The process we will follow is the same
as we used when including wind effects. A class named SpinProjectile will be written that will
be a subclass of WindProjectile . In this way the SpinProjectile class can use the code declared
in the ODE , SimpleProjectile , DragProjectile , and WindProjectile classes. The SpinProjectile
class starts off by declaring the fields that will be used to calculate Magnus force, namely the
angular velocity, radius, and spin axis.
public class SpinProjectile extends WindProjectile
{
private double rx; // spin axis vector component
private double ry; // spin axis vector component
private double rz; // spin axis vector component
private double omega; // angular velocity, m/s
private double radius; // sphere radius, m
The SpinProjectile constructor calls the WindProjectile constructor to initialize the fields
declared in the WindProjectile , DragProjectile , SimpleProjectile , and ODE classes. It then
provides initial values to the omega , radius , rx , ry , and rz fields.
public SpinProjectile(double x0, double y0, double z0,
double vx0, double vy0, double vz0, double time,
double mass, double area, double density, double Cd,
double windVx, double windVy, double rx, double ry,
double rz, double omega, double radius) {
// Call the WindProjectile class constructor.
super(x0, y0, z0, vx0, vy0, vz0, time, mass, area,
density, Cd, windVx, windVy);
 
Search WWH ::




Custom Search