This is a pair assignment. You should create a directory called assignment2 in cs120/assignments for this assignment. All code written for this assignment should be stored in that directory.
$ cd ~/cs120/assignments $ mkdir assignment2 $ cd assignment2
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.
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.
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.
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.
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.
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.
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:
Oscar Reutersvärd is Swedish artist most famous for creating geometric drawings that are simple to draw in 2 dimensions but represent things that are impossible to create in 3 dimensions. Loops are great for creating repetitive geometric designs like Reutersvärd did before the invention of the computer.
Create a Python program that uses the turtle module to Reutersvärd's Impossible Triangle like the following:
Reutersvärd is just one of several artists producing Impossible Figures. Do an image search for Impossible Figures and pick another cool impossible object to draw with turtle.
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:
Your program should include the traditional header, use appropriate variable names, and nicely label all values printed to the terminal. Submission are to be done through inquire.roanoke.edu through the Assignment 2 link. Both partners must submit through cseval!