Create a function, called drawProjectile, that draws out the Red Birds projected path. You have to use the Turtle graphics for this task. The following is required for your grade:The structureThe groundThe projected pathFor a Bonus (10 Points), the bird has to stop if the following happens:The bird hits the structureThe bird hits the groundBefore you begin programming, work an example by hand on paper. I suggest using the values from my sample interaction below. Make drawings to help you.
Question
Create a function, called drawProjectile, that draws out the Red Birds projected path. You have to use the Turtle graphics for this task. The following is required for your grade:The structureThe groundThe projected pathFor a Bonus (10 Points), the bird has to stop if the following happens:The bird hits the structureThe bird hits the groundBefore you begin programming, work an example by hand on paper. I suggest using the values from my sample interaction below. Make drawings to help you.
Solution
Sure, here is a basic example of how you might create this function in Python using the turtle module. This example does not include the bonus points for stopping the bird when it hits the structure or the ground.
import turtle
def drawProjectile(initial_velocity, angle_of_projection):
# Set up the screen
screen = turtle.Screen()
screen.bgcolor("white")
# Create a turtle to represent the bird
bird = turtle.Turtle()
bird.color("red")
# Create a turtle to draw the ground
ground = turtle.Turtle()
ground.color("black")
ground.penup()
ground.goto(-300, -200)
ground.pendown()
ground.forward(600)
# Set the initial position and velocity of the bird
bird.penup()
bird.goto(-200, -200)
bird.pendown()
velocity_x = initial_velocity * math.cos(angle_of_projection)
velocity_y = initial_velocity * math.sin(angle_of_projection)
# Simulate the flight of the bird
for _ in range(1000):
x = bird.xcor()
y = bird.ycor()
velocity_y = velocity_y - 9.8 # Gravity
bird.goto(x + velocity_x, y + velocity_y)
# Hide the turtles
bird.hideturtle()
ground.hideturtle()
# Keep the window open
turtle.done()
This function simulates the flight of the bird by updating its position and velocity at each time step. The bird's horizontal velocity remains constant, while its vertical velocity decreases due to gravity. The bird's path is drawn on the screen using the turtle graphics module.
Please note that this is a very basic simulation and does not take into account factors such as air resistance or the rotation of the bird. Also, the bird does not stop when it hits the ground or any structure. You would need to add additional code to implement these features.
Similar Questions
I’m sure all of you have played or seen the popular game, Angry Birds. The basic concept is to fling a bird at a structure and try to knock it down. For this project will focus on the physics and trigonometry of the Red Bird’s attack. The Red Bird does not doing anything special, just aim and shoot. With several basic concepts of programming, you can write a program that puts many of your skills to use together to predict whether or not the Red Bird will successfully hit the target.First, let's take a moment and recall some basics of kinematics from our intro. physics experience. I am assuming you've all taken introductory physics and trig. When you fling the Red Bird, it becomes a projectile and will be governed by the laws of kinematics. The Red Bird is flung with some velocity, which is a vector quantity. That means it has both a magnitude and direction We'll express the direction as an angle with respect to the horizontal. When we do computations, we need to resolve the vector quantities into components and work with the x direction separately from the y direction. Recall that we resolve a vector v at direction θ into its horizontal and vertical components using trigonometry:vx = v (cos θ)vy = v (sin θ)We can then use the equations of kinematics:vf = vi + atvf2 = vi2 + 2add = vit + (1/2)at2wherevf = final velocityvi = initial velocitya = accelerationt = timed = distanceIn the vertical direction, the acceleration we use is the constant acceleration due to gravity, g = -9.8 m/s2. In the horizontal direction, the projectile does not experience any acceleration (which simplifies Equation #3 above for our computations).Hints: Once you've resolved the projectile into x- and y-components, begin by working with Equation 3 to find the time to reach the desired horizontal position. Then you can use Equation 3 to find the vertical position at the same time.Project Details:Create a function, called inputData, that gathers the following inputs from the user:The magnitude of the velocity with which the Red Bird was flung, in m/sThe angle with respect to the horizontal of the velocity vector, in degreesThe horizontal distance to the structure you're trying to knock down with the Red Bird, in mThe height of the structure you're trying to knock down with the Red Bird, in mReturn all four values from this function, like this:#return inside inputData function return a, b, c, d...#where you call the functionvel, ang, dist, h = inputData()You may assume the following:Assume the height from which the Red Bird is flung is a constant of 5 m. Make sure the user knows this information to scale the height of the structure accordingly.Your toss will be perfectly along the line between you and your target, i.e. you don't need to worry about the toss going to the left or the right.Since it is a video game, there's no wind. There is no air resistance/wind resistance that we must take into account, i.e. the "ignore friction and air resistance" clause that's standard in most introductory physics books applies here.The calculations will be completed inside of a function called calcProjectileMotion. The parameters for this function should be (in this order but names can vary): input velocity, input angle (in degrees), input distance to target, input height of targetYour objective is to compute the following values and return them in a Dictionary (call it results):“Time” = The time it takes for the Red Bird to reach the target.“FinalVelocity” = The velocity of the Red Bird when it reaches the target distance.“FinalAngle” = The direction of the Red Bird when it reaches the target distance.“Height” = The height of the Red Bird when it reaches the target distance“HitTarget” = Whether the Red Bird hits the structure, the toss is too short, or the toss is too long. This should be int value:-1 = too short0 = hit target1 = too long
The bird in the image is flying to the right. It has four forces acting on it, as shown by the arrows.Analyse the diagram to decide how the bird's motion will change as an effect of the forces.Slow downMove downSpeed up to the rightMove upForce diagram for a bird flying in the air.
Draw the feet of three different bird species and explain why they are shaped that way
You are tracking the migration patterns of birds in a wildlife reserve using a coordinate plane.Bird 1 🦜 is currently located at a point where the X-coordinate is -2, and the Y-coordinate is 4. Bird 2 🐦 is located where the X-coordinate is 0, and the Y-coordinate is -6.Identify the ordered pairs for both birds' locations.
Which library is commonly used in Python Turtle programming for drawing graphics?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.