- #1
squid
- 14
- 0
Given a projectile at position '(x0, y0)' and a launch angle 'a', at which speed must I launch the projectile to make it pass through a point '(x, y)', assuming that the only force that acts upon it is gravity (which causes acceleration 'g')?
I came up with the following:
vx0 = s * cos(a)
vy0 = s * sin(a)
x = x0 + vx0 * t
y = y0 + vy0 * t + g/2 * t^2
x = x0 + s * cos(a) * t
y = y0 + s * sin(a) * t + g/2 * t^2
s = -((x0 - x) * sec(a)) / t
y = y0 -((x0 - x) * sec(a)) / t * sin(a) * t + g/2 * t^2
y = y0 - (x0 - x) * tan(a) + g/2 * t^2
t = +- (sqrt(2) * sqrt(y - y0 - x * tan(a) + x0 * tan(a)) / sqrt(g)
But there's no point in going any further because of 'sqrt(g)', which is a square root of a negative value.
I tried doing it the other way around, but that also yields a complex solution.
Can anyone help me out with this?
I came up with the following:
vx0 = s * cos(a)
vy0 = s * sin(a)
x = x0 + vx0 * t
y = y0 + vy0 * t + g/2 * t^2
x = x0 + s * cos(a) * t
y = y0 + s * sin(a) * t + g/2 * t^2
s = -((x0 - x) * sec(a)) / t
y = y0 -((x0 - x) * sec(a)) / t * sin(a) * t + g/2 * t^2
y = y0 - (x0 - x) * tan(a) + g/2 * t^2
t = +- (sqrt(2) * sqrt(y - y0 - x * tan(a) + x0 * tan(a)) / sqrt(g)
But there's no point in going any further because of 'sqrt(g)', which is a square root of a negative value.
I tried doing it the other way around, but that also yields a complex solution.
Can anyone help me out with this?