Game Development Reference
In-Depth Information
Let's use Equations (7.21) and (7.23) to compute the Magnus force and acceleration on the
golf ball analyzed in the “A Sample Collision Analysis” section. The golf ball had post-collision
x- and z-components of velocity equal to 70.6 and 10.4 m/s . The post-collision angular velocity
of the ball was -290.4 rad/s . We'll assume the air density is equal to the sea-level value of
1.225 kg/m 3 . The Magnus force equation is based on the translational velocity magnitude, v ,
which can be found from Equation (5.15).
m
s
(7.24)
2
2
v
=
70.6
+
10.4
=
71.4
The rotational spin ratio is equal to the product of the golf ball radius, r b , and the angular
velocity, w , divided by the translational velocity magnitude.
r
v ω =−
0.02135* 290.4
=−
0.087
(7.25)
71.4
The Magnus force lift coefficient is found by plugging the rotational spin ratio value shown
in Equation (7.25) into Equation (7.23), making sure to use the absolute value of the rotational
spin ratio.
(
)
C
=−
0.05
+
0.0025
+
0.36 0.087
=
0.134
(7.26)
L
The magnitude of the Magnus force can now be computed from Equation (7.21).
1
2
N
FCv A
=
r
=
0.6
(7.27)
M
L
2
A Golf Game
Let's take what we've covered so far and develop a golf game. Similar to the golf games that
were developed in Chapter 5, the object of this game will be to hit the ball onto the green from
a certain distance away. The user selects a club and an impact velocity. Other text fields allow
the user to specify the wind velocity, air density, distance to hole, and spin axis. If your shot
lands within 8 m of the hole, you are “on the green” and you win. A sample screen shot of the
GUI is shown in Figure 7-8.
The nice thing about the Golf Game from a code developer point of view is that most of the
work has already been done. A class named GolfBall will be written to represent the golf ball.
The GolfBall class will be written as a subclass of the SpinProjectile class that was developed
in Chapter 5. The Golf Game GUI is very similar to the GUIs for the Golf Games developed in
Chapter 5 except that here the user chooses a club rather than specifying the initial velocity
components of the ball.
Search WWH ::




Custom Search