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
Question
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
Solution
Sure, here is a step-by-step guide on how to approach this problem:
- Input Data Function: First, you need to create a function that will gather the necessary inputs from the user. This function should ask for the magnitude of the velocity, the angle of the velocity vector, the horizontal distance to the structure, and the height of the structure. These values should be returned from the function.
def inputData():
a = float(input("Enter the magnitude of the velocity (m/s): "))
b = float(input("Enter the angle of the velocity vector (degrees): "))
c = float(input("Enter the horizontal distance to the structure (m): "))
d = float(input("Enter the height of the structure (m): "))
return a, b, c, d
- Calculate Projectile Motion: Next, you need to create a function that will calculate the projectile motion of the Red Bird. This function should take the input velocity, input angle, input distance to target, and input height of target as parameters.
import math
def calcProjectileMotion(vel, ang, dist, h):
g = 9.8 # acceleration due to gravity
ang_rad = math.radians(ang) # convert angle to radians
# calculate time to reach target
t = dist / (vel * math.cos(ang_rad))
# calculate final velocity
vf = math.sqrt((vel * math.cos(ang_rad))**2 + (vel * math.sin(ang_rad) - g * t)**2)
# calculate final angle
final_ang = math.degrees(math.atan((vel * math.sin(ang_rad) - g * t) / (vel * math.cos(ang_rad))))
# calculate height at target
height = vel * t * math.sin(ang_rad) - 0.5 * g * t**2
# determine if hit target
if height < h:
hit_target = -1 # too short
elif height > h:
hit_target = 1 # too long
else:
hit_target = 0 # hit target
# return results in a dictionary
results = {"Time": t, "FinalVelocity": vf, "FinalAngle": final_ang, "Height": height, "HitTarget": hit_target}
return results
- Main Program: Finally, you need to call these functions in your main program.
def main():
vel, ang, dist, h = inputData()
results = calcProjectileMotion(vel, ang, dist, h)
print(results)
if __name__ == "__main__":
main()
This program will first gather the necessary inputs from the user, then calculate the projectile motion of the Red Bird, and finally print the results.
Similar Questions
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.
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.
When traversing cluttered environments at nearly cruising speeds, birds need to be constantly aware of the distances to oncoming obstacles and the spaces between them to make split-second decisions about whether a gap can be traversed and to determine whether a change in the wing posture is necessary to facilitate an injury-free passage. Do birds fly through passages that are narrower than their wingspan? If so, what postural changes do they make to accommodate the passage? Seven budgerigars (Melopsittacus undulatus) were confronted with an aperture of variable width in the experiments. We aimed to investigate their flight maneuvers through the aperture and to enquire whether they display awareness of their body size.6 Mark For Review6Which choice best describes the function of the underlined sentence in the overall structure of the text?A) It implies that scientists will never be able to describe bird flight patterns with certainty. B) It introduces various elements of bird flight patterns that the researchers wanted to study. C) It discredits previous research on bird flight patterns, which relied on a flawed methodology. D) It shows that the scientific community frequently questions the relevance of bird flight patterns.
A bird moves from point (1, -2) to (4, 2). If the speed of the bird is 10 m/sec, then the velocity vector of the bird is
A bird is flying along the straight line 2𝑦−6𝑥=42y−6x=4. In the same plane, an aeroplane starts to fly in a straight line and passes through the point (4,12)(4,12). Consider the point where aeroplane starts to fly as origin. If the bird and plane collides then enter the answer as 1 and if not then 0. Note: Bird and aeroplane can be considered to be of negligible size.
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.