- #1
TimTimTim
- 4
- 0
At first this sounds like a very popular and often asked/solved question but it has a twist - I need help with the twist please.
1. Homework Statement
A cannon is at Point A in a 3d environment.
There is a wall at Point B which sits between the cannon and a castle, at Point C.
Write a function that will find the angle and initial velocity required to fire a cannonball so that it just passes the top of the wall and hits the castle. (Meaning it should be in the air for the shortest time possible). I also assume this is easier to work out by considering the top of the wall and the castle as two points the ball must pass through.
The cannon has no limit on it's power - so the initial velocity can be anything.
The twist - The wall that the cannonball must get over is not at the midpoint between the cannon and the castle, it may instead be at any distance between the cannon and the castle (and at any height).
The variables: cannon position, wall height and position, castle position.
The knowns: the cannon's power is unlimited, the cannon's angle is anywhere between 0 and 90 degrees from the horizontal, gravity.
y = v0yt -.5gt^2
x= v0xt
I've solved it for when the wall blocking the cannon and castle is directly in the middle of the parabolic arc. However I don't know what formulas to use or how to work out the required formula for when the wall is not directly in the middle. Just to be clear; if the cannon was at 0,0 and the castle was at 100,0 then the wall could be at any point along the x-axis between 0 and 100... 0<wall<100.
1. Homework Statement
A cannon is at Point A in a 3d environment.
There is a wall at Point B which sits between the cannon and a castle, at Point C.
Write a function that will find the angle and initial velocity required to fire a cannonball so that it just passes the top of the wall and hits the castle. (Meaning it should be in the air for the shortest time possible). I also assume this is easier to work out by considering the top of the wall and the castle as two points the ball must pass through.
The cannon has no limit on it's power - so the initial velocity can be anything.
The twist - The wall that the cannonball must get over is not at the midpoint between the cannon and the castle, it may instead be at any distance between the cannon and the castle (and at any height).
The variables: cannon position, wall height and position, castle position.
The knowns: the cannon's power is unlimited, the cannon's angle is anywhere between 0 and 90 degrees from the horizontal, gravity.
Homework Equations
y = v0yt -.5gt^2
x= v0xt
The Attempt at a Solution
I've solved it for when the wall blocking the cannon and castle is directly in the middle of the parabolic arc. However I don't know what formulas to use or how to work out the required formula for when the wall is not directly in the middle. Just to be clear; if the cannon was at 0,0 and the castle was at 100,0 then the wall could be at any point along the x-axis between 0 and 100... 0<wall<100.