An angry bird is shot at an angle to the horizontal at a speed . The ground is steep, inclined at an angle . Find the horizontal distance 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 and an angry bird being fired at angle at speed ” />
Make a function that returns the length : the horizontal distance that the bird traveled before it hit the ground.
Constrains and notes:
- Assume acceleration due to gravity .
- You may use radians instead of degrees for , .
- Dimensions of are irrelevant as long as they are consistent with and .
- No air resistance or anything too fancy.
Shortest code wins.
See the Wikipedia article on projectile motion for some equations.
f(0, 45, 10) = 10 f(0, 90, 100) = 0 f(26.565, 45, 10) = 5 f(26.565, 135, 10) = 15