0

An angry bird is shot at an angle β to the horizontal at a speed u. The ground is steep, inclined at an angle α. Find the horizontal distance q that the bird traveled before it hit the ground.

<img src="https://i.stack.imgur.com/fToDM.png" alt="diagram showing an inclined plane at angle alpha and an angry bird being fired at angle beta at speed u” />

Make a function f(α, β, u) that returns the length q: the horizontal distance that the bird traveled before it hit the ground.

Constrains and notes:

  • -90 < α < 90.
  • 0 < β < 180.
  • α < β.
  • 0 le u < 10^9.
  • Assume acceleration due to gravity g = 10.
  • You may use radians instead of degrees for α, β.
  • Dimensions of u are irrelevant as long as they are consistent with g and q.
  • No air resistance or anything too fancy.

Shortest code wins.

See the Wikipedia article on projectile motion for some equations.

Samples:

f(0, 45, 10) = 10
f(0, 90, 100) = 0
f(26.565, 45, 10) = 5
f(26.565, 135, 10) = 15