# CPSC120 Assignment 4

## Ballistic Simulation

The first electronic programmable computer, ENIAC, was created for performing ballistic calculations for the United States Army. ENIAC was the size of a school bus and weighed 30 tons. You can do the same calculations on your computer.

### Details

Create a function that draws the path of a projectile. The path of the projectile is determined by the initial position of the projectile, the initial velocity of the projectile, gravity, and wind. Each of these values should be parameters to the function. The program should also have a parameter for the number of line segments of the projectile’s path to compute and draw.

The initial position of the projectile is the number of pixels from the origin in both the x and y directions. The initial velocity of the projectile is the change in the projectile’s position in pixels per update in both the x and y directions. Gravity is the change in the projectile’s velocity in update per update squared in the negative y direction. Wind is the change in the projectile’s velocity in pixels per update squared in both the x and y directions.

The function should approximate the projectile’s path with a series of line segments. Each line segment can be calculated by using the projectile’s current velocity to calculate where it will be next, assuming it travels on a straight line. The new position can be calculated by adding the velocity to the old position. Every time the new position is calculated a new velocity should also be calculated. The new velocity can be calculated by subtracting the gravity from the y velocity and adding the wind to the x and y velocity. Gravity is a non-negative real number that controls how quickly the projectile falls. Wind is a constant force, like gravity, but it can be in any direction and therefore has both x and y components.

### Submission

Test: Submit your test fiels as a zip file on the course Inquire site by 9AM on Monday October 1st.

Code: Submit your code as a zip file on the course Inquire site by 5PM on Friday October 5th.

### Extra

Air Resistance: Add air resistance to the simulation. Air resistance is an acceleration that is always the opposite direction as the velocity. The x and y components of the air resistance must therefore be recalculated every time the velocity is updated.

The Monkey and the Hunter: The monkey and the hunter is a classic physics question. If a hunter aims a dart gun directly at a monkey hanging on a branch and the monkey lets go at the same instant the hunter fires, will the monkey be hit? Simulate this by creating two projectiles. One projectile, the monkey, with an initial velocity of 0 in both the x and y direction. The other projectile, the dart, with an initial velocity directly toward the initial location of the monkey.