CPSC120A
Fundamentals of Computer Science I

Scientific Assignment 2

Use Python for ballistics 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. A lot has changed over the years, to the point where pocket sized computers (Cell Phones) now have more computational power than the ENIAC. For this assignment, you will use your modern day computer and the turtle module to perform similar calculations.


Details

Using the Turtle module, your program should draw a series of 3 concentric circles on the right hand side of the screen. These circles will represent the target that your ballistic simulation will be aiming for.

Your program is going to launch projectiles from the lower left corner of the window. To accomplish this, your program should prompt the user to enter both an initial x component of velocity, and an initial y component of velocity.

Given this information, your program should draw some fixed number of lines segments that will approximate the ballistic trajectory of the launched projectile. Each line segment can be calculated by using the projectile's current velocity to compute the new location of the projectile (assuming the projectile is traveling in a straight line). Once you compute the new position, you then need to compute the new velocities in the x and y directions. You can do this by simply subtracing the acceleration due to gravity (9.81 m/s2) from the y component of velocity, and adding the acceleration due to wind (Which we will assume for now is 1 m/s2).

Keep in mind that your program does not need to stop when the user hits the target, nor does your program need to stop when the turtle leaves the screen. You simply need to draw some fixed number of line segments to represent the projectile path.


"Hacker" Prompt

Each week, additional exercises related to the assignment will be provided at the end. These exercises are typically more challenging than the regular assignment. Bonus points will be provided to students who complete any of the "Hacker" level assignments.

  1. Continued Play: Right now, your program stops after the first projectile. For this hacker prompt, you should restructure your program such that, after the first projectile, it asks again for another set of x and y velocities. This should continue for some fixed number of steps.

  2. Air Resistance: The code above assumes the projectiles are fired in a vacuum. While space combat seems fun, it's not very useful for Earth based projectiles. Add air resistance to the simulation. Air resistance is an acceleration that is always opposite the direction of the velocity. Thus the x and y components of the air resistance must be recalculated every time velocity is updated.

  3. The Monkey and the Hunter: The monkey and the unter 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.


Grading

The assignment will be graded on the following requirements according to the course’s programming assignment rubric.

Functionality (75%): A functional program will:

Style (25%): A program with good style will:

Submission

Submit your program as a .py file on the course Inquire page before class on Wednesday September 23rd.