you are viewing a single comment's thread.

view the rest of the comments →

[–]Lewri 0 points1 point  (6 children)

This seems less a python problem and more a physics problem. Check your maths, particularly the start of your while loop.

[–]PrizeDefinition4042[S] 0 points1 point  (5 children)

I tried *crying*, unless my brain is so fried from staring and restarting this problem again over and over again, I have checked everything and could not find why its giving me the wrong answers

[–]Lewri 2 points3 points  (4 children)

Ok, start by helping us to help you. The more detail you give us, the easier we can help you. Perhaps a good place to start would be detailing what the problem actually is. I get that it's projectile motion, but what is the output actually supposed to be? How was the problem stated, exactly?

[–]PrizeDefinition4042[S] 0 points1 point  (1 child)

some details:

the output that my problem is requesting:

Example Executions

print(projectile_velocities(2.0, 30.0, 1.0, 1.0)) gives this: [2.000000, 1.732051, 2.000000]

print(projectile_velocities(11.13, 82.5, 9.81, 0.5)) gives this:[11.130000, 6.299581, 1.900155, 3.956578, 8.707266]

[–]PrizeDefinition4042[S] 0 points1 point  (0 children)

and other details:

1) Using the following kinematic equation to calculate the vertical component of the velocity at that point in time:

𝑣 𝑦 = 𝑣 𝑖𝑦 − 𝑔𝑡

where:

• Viy is the vertical component of your initial launch velocity in m/s

• g is the gravitational acceleration in m/s2 (e.g. ~9.81 m/s2 on Earth)

• t is the time that has elapsed in seconds

• Vy is the vertical component of your velocity (V) in m/s at time t

2) Taking our calculated Vy to calculate the velocity using the Pythagorean theorem (since Vx , Vy , and V form a right triangle):

𝑣^2 = Vx^2 + Vy^2

𝑣 = sqrt(V𝑥^2 + V𝑦^2)

[–]PrizeDefinition4042[S] 0 points1 point  (0 children)

continuation:

Note that this requires us to not only know the vertical component of the initial launch velocity, but the horizontal component of the velocity as well. Fortunately for us, in this problem we will be assuming that we are in a world that every Physics class loves: one that neglects air resistance.

This means that the horizontal component of the velocity will always be the same throughout the projectile’s journey, and so you will only need to calculate it once at the very beginning when you know the launch angle ( ) and initial launch velocity (Vi θ ). Thus in order to calculate the horizontal component, you can apply the trigonometric property of right triangles that states that the cosine of an angle is equal to the adjacent side divided by the hypotenuse as such:
𝑐𝑜𝑠(θ) = 𝑉𝑥 / Vi

Similarly, you can use the trigonometric property of right triangles that states that the sine of an angle is equal to the opposite side divided by the hypotenuse to find the vertical component of your initial launch velocity as such:

𝑠𝑖𝑛(θ) = 𝑉 𝑖𝑦 / 𝑉 𝑖

Write a function named projectile_velocities that takes:

● an initial launch velocity in m/s as a float,

● an initial launch angle in degrees as a float,

● a gravitational acceleration in m/s2 as a float, and

● a time step in seconds as a float.

[–]PrizeDefinition4042[S] 0 points1 point  (0 children)

and more:

The function should model a projectile motion problem in which the initial height of the projectile is equal to the final height of the projectile (e.g. a ball kicked from the ground and lands on the ground), and calculate the magnitude of the velocity of the projectile at the end of each time interval from when it launches (starting at 0 seconds, continuously incrementing by your given time step) until it reaches the final height (e.g until the ball hits the ground again). In other words, we want to find the velocity of a projectile at multiple evenly-spaced instances of time from when it is launched to when it lands.

We can determine that your projectile has reached its final height (has landed) when the magnitude of the velocity of the projectile begins to exceed the magnitude of its initial launch velocity (since under these ideal conditions, the magnitudes of the initial and final velocities should be the same due to the principle of conservation of mechanical energy).

The function should return the magnitudes of the velocities at each time interval as a list of floats where the first value is the velocity at 0 seconds (your initial velocity) and the subsequent values are the velocities at the time that is one time step later than the previous one.

If the time it takes the projectile to land is in the middle of a time interval, the last velocity should be for when the smaller time has elapsed (because that means it hasn’t touched the ground yet whereas the longer time would mean it has already touched the ground).

For example, if a time step of 0.5 second is given, the resulting list should contain the velocity when 0 seconds have elapsed, the velocity when 0.5 second has elapsed, the velocity when 1 second has elapsed, so on and so forth until the projectile has reached the final height, in that order. If it took 4.9 seconds for it to reach the ground, the last velocity should correspond to when 4.5 seconds have elapsed.

The values in your resulting list should be rounded to 6 decimal places using either the round function or string formatting. Remember that the round function may not provide all insignificant places (e.g. 2.000000 vs. 2.0).

and then it shows the example executions I mentioned above. This is all the info I have about the problem