CS 161

3/16/10

Tornado Simulation

David Schwartz

Description: This program simulates a simplistic Tornado, that sucks and accelerates objects from the ground up into its whirling vortex, and then sends them up into the sky.

Images:











User Keyboard Controls:

w a s d = move tornado forward, left, down, right

u = speed up tornado rotation j = slow down tornado rotation

i = increase tornado height k = decrease tornado height

Program Details: For this simulation, I did not try to recreate the physics of a real tornado, because it would go beyond the scope of my abilities in the given time. Instead, I constructed a simplified tornado that mimics people's common perceptions of what a tornado should do. Most of the programming work I did involved physics, and manipulating the tornado's variables.

The Tornado moves about the Z-axis, and an object enters the tornado when the tornado's bottom tip passes directly over the object. The tornado then applies an upward acceleration on the object, as well as rotating it around the Tornado's Y-axis, so that the object spins along with the tornado. Once the object accelerates to the top of the tornado, it stops accelerating and moves according to its instantaneous speed, while the de-acceleration of gravity begins to take hold. I used basic physics equations such as x = 1/2at^2 and v = at to calculate these parameters, and had two separate timers: one for the ascent up the tornado, and another for the falling from the top of the tornado to the ground. In order to get the proper effect, the objects rotation radius (the radius of the circle of rotation) was dependent on the objects current height.

At the top of the tornado, the resulting x and z velocities' direction of the object would be tangent to its position along the rotation circle. I used the angle of rotation to calculate the proper x and z velocities, using zVelocity = -cos(angle), and xVelocity = -sin(angle). This ensured that the object would fly off in the right direction. When the user changes the height of the tornado, the program compensates by increasing the rotation radius. That is, the rotation radius is dependent both on the objects current height, and also the total height of the tornado. This ensures that Tornado's of different heights and sizes will produce unique results.

The speed of the tornado can also be increased or decreased, which not only effects the speed of rotation, but also the tornado's upwards acceleration and its velocity after it leaves the tornado. A tornado that is spinning faster will accelerate an object upwards faster, and also leave it shooting out from the top of the tornado faster.

Link to Video

Link to main source code