Game Development Community

Mortar Ballistics

by David Smith · 03/03/2006 (1:56 pm) · 6 comments

I have been working on this problem for some time now, and I have gotten nowhere. Consider a mortar in a FPS game, where the distance and height difference between the 2 entities are known variables. What I have so far is:

angles[YAW] --- left right [0...360] degrees
angles[PITCH] --- up down [0...90] degrees
angle = angles[YAW] * (M_PI * 2 / 360)
sy = sin(angle)
cy = cos(angle)
angle = angles[PITCH] * (M_PI * 2 / 360)
sp = sin(angle)
cp = cos(angle)
forward[0] = cp * cy
forward[1] = cp * sy
forward[2] = -sp
forward[0] = forward[0] * 3300
forward[1] = forward[1] * 3300
forward[2] = forward[2] * 1650

Length of this vector is the speed of the projectile. In the calculation the speed of the projectile is different at different angles. You will notice that the speed is not depended on YAW angle but only on PITCH angle. The speed goes from 1650 at PITCH of 90 degrees and to 3300 at PITCH of 0 degrees. All the middle values are determined by the upper formulas. Hopefully all this can be simplified so YAW angle won't be in the equation. The launch speed is determined by the angle, so basically it is another variable and not a constant in the calculations. So, would the following equation be correct : launch_speed = sqrt [3300^2 * cos^2(PITCHangle) + 1650^2 * sin^2(PITCHangle)]. Hope it is right I just did it by heart. And of course this can be reduced down to use only cos or sin. The following equations were my initial ones I was using :

v_o is the velocity of the projectile
v_x(t) is the x speed at time t
v_y(t) is the y speed at time t
theta is the launch angle
h is the maximum height of the projectile
b is the landing height of the projectile
R is the total distance traveled in x

Formulas for targets higher than the launch point
x(t) = v_o * cos(theta) * t
y(t) = v_o * sin(theta) * t
v_x(t) = v_o * cos(theta)
v_y(t) = v_o * sin(theta) - g * t
v(t) = sqrt(v_o^2 - 2 * g * t * v_o * sin(theta) + (g * t)^2)
h = (v_o^2 * sin(theta)^2) / 2 * g
R = v_o * T * cos(theta)
T = (v_o * sin(theta) / g + sqrt(2 * (h - b) / g)

Formulas for targets lower than the launch point
x(t) = v_o * cos(theta) * t
y(t) = v_o * sin(theta) * t
v_x(t) = v_o * cos(theta)
v_y(t) = v_o * sin(theta) - g * t
v(t) = sqrt(v_o^2 * 2 * g * t * v_o * sin(theta) + (g * t)^2)
h = b + (v_o^2 * sin(theta)^2) / (2 * g)
R = v_o * T * cos(theta)
T = (v_o * sin(theta) / g + sqrt( 2 * h / g)

For horizontal motion ->
Horizontal velocity =
a_x = 0
v_x = v_ox
Horizontal distance =
x = v_ox * t

For vertical motion ->
Vertical velocity =
a_y = -g = 9.8 m/s^2
v_y = v_oy - g * t^2
Vertical position =
y = v_oy * t - 0.5 * t^2

About the author

Recent Blogs


#1
03/03/2006 (2:19 pm)
um, my question to you.....

what are you trying to do? figure the aiming method for bots?

or are you trying to determine the projectile's path once it launches?

it looks to me that whatever you are trying to do, you are being a bit too complicated in your thinking...

mind you, I havent took more than basic college physics, and that was about 9 years ago!
#2
03/03/2006 (2:43 pm)
Dave,

I'm not an expert on mortars, but I don't see how the launch speed would change based on the angle; I think that its constant.

BTW, this should probably be asked in a forum post rather than a plan.
#3
03/03/2006 (2:56 pm)
The launch speed won't change based on the angle, it should always remain the same. Well not completely true, it will but since gravity doesn't have any major effect untill the projectile is out of the barrel, the effect of gravity would be.... minimal.... Please, make a forum thread out of this, I'd LOVE to see where this would end up :)

[Ishbuu]
#4
03/03/2006 (4:35 pm)
http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html

Get yerself there bud..

Phil.
#5
03/03/2006 (10:51 pm)
Ok made forum post
http://www.garagegames.com/mg/forums/result.thread.php?qt=40921
And in regards to the change in velocity due to the angle, that is the way the game engine is set up. I know it's wrong but that's the way they wrote it. Jason, all i am trying to do is hit a certain point, but as I stated earlier, the problems arise with the variable speed.
#6
03/04/2006 (4:51 am)
Already one thread in process on this for awhile now. The equations for the firing angle for targets at different heights has been established, I think. Have you tried those results? I haven't tried them in game.

www.garagegames.com/mg/forums/result.thread.php?qt=35862