Skip to content

Instantly share code, notes, and snippets.

@fospathi
Created July 31, 2018 10:24
Show Gist options
  • Save fospathi/d370061ea1967c9adf485179c4fdaaf7 to your computer and use it in GitHub Desktop.
Save fospathi/d370061ea1967c9adf485179c4fdaaf7 to your computer and use it in GitHub Desktop.
Aimed projectile launch angle
An expression for the launch angle of a parabolic projectile which coincides with a target position vector (x, y) at some
point in its trajectory.
The parametric coordinates of a parabolic projectile launched from the origin are
x = uct
y = ust + at² / 2
where
u is the initial velocity
a is the acceleration
t is the time since launch
θ is the launch angle
s = sin(θ)
c = cos(θ)
Eliminating t we get
y = x tan(θ) + ax²/(2u²c²)
= x tan(θ) + (tan²(θ) + 1)ax²/(2u²)
Thus
0 = (ax²/(2u²)) tan²(θ) + x tan(θ) + (ax²/(2u²)) - y
This is a quadratic equation in tan(θ) which can be solved for tan(θ)
Let
A = (ax²/(2u²))
B = x
C = A - y
Then
0 = A tan²(θ) + B tan(θ) + C
and
θ = arctan( -B±√(B² - 4AC) )
( -------------- )
( 2A )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment