Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem about missile

  1. Jul 2, 2007 #1
    Hi, firstly, sorry about my bad english... I am an Spanish preuniversitary student who's programing a game in the style of "Worms" in 2D.
    My problem comes about a weapon that acts like a missile. I'll explain it (it's just an cinematic study, the game doesn't care about mass and dynamics).
    The weapon is a mobile object. There are three accelerations acting over it:
    - The constant acceleration of gravity, directed to "down" which value is g.
    - The constant acceleration of wind, directed to "right", which value is w.
    - The acceleration of the engine of the missile, which magnitude is p. The direction of this acceleration is variable: the missile accelerates in the same direction of its velocity. In consequence, the equations of this accelerations will be something like this:

    a_x = w + p cos #
    a_y = g + p sen #
    where # is the angle of the direction of the missile.
    If we look on that cos # = dv_x / dv , sen # = dv_y / dv , the equations will be:

    a_x = w + p (dv_x / dv)
    a_y = g + p (dv_y / dv)

    My question is, how can I change this differential equations into parametric equations depending on time? I mean, x=f(t), y=g(t)
    The movement will have an initial velocity, v_x0, v_y0; and you can supose the movement begins in x=0, y=0.

    Thanks in advance! :)
  2. jcsd
  3. Jul 2, 2007 #2
    I think yo need to know the function of the angle in time, lets say #(t), and then simply integrate two times over each aceleration to have x and y in function of time.

    For example, if #=90º, then you have a_x=w, a_y=p-g, making some integration....

    v_x=v_x0+w*t, x=x_0+v_x0*t+0'5*w*t^2. Knowing that x_0=0, then you have that:


    And the same for y:


    You need to know some of the dependence with time of the angle.
    Last edited: Jul 2, 2007
  4. Jul 2, 2007 #3


    User Avatar
    Homework Helper

    A normal "dumb" rocket is "positively stable" (center of cross pressure behind center of mass), and a cross-component of wind will just cause the rocket to "weather vane" into the wind, until there is no cross component, so it would "lean" into the wind, and end up accelerating into the wind. This is assuming that the rocket doesn't have any "intelligent" stability control, such as gyro sensors and side thrust control.

    If the rocket were "neutrally stable", so that a cross wind didn't result in a yaw reaction, the the rocket would end up with no acceleration due to the wind, just a velocity component equal to the wind. If the initial condition was vertical only velocity, the rocket would remain pointed vertically, but would travel horizontally with the speed of the wind (but no horizontal acceleration).

    It would probably be eaiser to ignore the initial effects of the wind and just add a horizontal component of velocity that is the same as the wind after the rest of the calculations are done. The rocket's orientation should be in the direction of travel relative to the air it's flowing through.

    In real life, when aerodynamic drag is factored in, the differential equations get too complicated to solve directly, so acceleration is calculated from velocity and position (thinner air, weaker gravity at altitude), then numerical integration is done in a small step of time to predict new velocity (and orientation) and position, and this cycle is repeated in small steps.
    Last edited: Jul 2, 2007
  5. Jul 2, 2007 #4
    Thank you for the answers, but I'm afraid you haven't understood what I tried to say.
    To Coren: That's why I am asking for help! :P Let's see:
    The angle, #, is not dependable on time. It depends on the velocity, more exactly, on the direction of the velocity. When I made the engine of the game, I supossed that the missile was always pointing at the place where the missile would go if it went on with inercial movement (without acceleration). In fact, you obtain the differential equations I wrote before... and that's where I don't know how to continue. Thank you!
    To Jeff Reid: Thank you for your explanation, it's very good! But what I am trying to make is a very simply game, not a real rocket ;) Anywhere, I keep needing answers to my problem...
  6. Jul 2, 2007 #5


    User Avatar
    Homework Helper

    Which is why I suggested ignoring any acceleration due to wind, and just add a velocity component for the wind after all the other calculations are done.
  7. Jul 4, 2007 #6
    I can't ignore it! :P

    OK, I understand what you say. But, anyway, I can't ignore the wind acceleration. If you've ever played a "Worms" game, you'll understand why. In that game, rockets are very affected by wind (sometimes even more than by gravity), so wind has a great influence over the angle # of the missile.
  8. Jul 7, 2007 #7
    Here is what you want.

    Sign(z) must return the algebraic sign of Z. You can code it with something like z/(Abs(z). This is used to ensure that the air resistance only slows the projectile, regardless of the direction it is traveling.

    The parameter A will determine the strength of the air resistance, and you should just play with values until the animation looks right.

    a_x = -Sign(v_x-v_w) A*(v_x-v_w)^2 + Sign(v_x-v_w) p_x (notice the v_w part goes to zero at v_x = v_w)

    a_y = -g - Sign(v_y) A*(v_y)^2 + Sign (v_y) p_y

    where v_w is the wind speed (positive if it goes in the positive x direction), and _x and _y indicate multiplication by the proper trig ratios.

    It is not so easy to just turn these into (analytical) functions of time, but it is quite simple to do it iteratively. Define initial values for your velocity, and a time step (dt) (to coincide with the simulation time beween frames), then evaluate a_x. Set v_x to v_x + a_x *dt, and x = x + v_x * dt. (and the same for y). Draw your frame, and then run this sequence again as a loop until impact or whichever exit event.
    Last edited: Jul 7, 2007
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Problem about missile
  1. Problem about entropy (Replies: 13)