Ballistic Simulation Problem

This forum is currently in read-only mode.
  • Hi!

    I have spent the whole day trying to figure out the equations having to do with drag on objects with a fixed mass.

    My example which I included is kinda like a classic cannon shooting example(Platform-scrolling).

    I have figured out how to implement gravity and convert it to pixels.

    (1 meter = 32 pixels)

    My problem is drag, and how to implement it.

    I found this:

    grc.nasa.gov/WWW/k-12/airplane/flteqs.html

    (alot of interesting articles)

    This is the formula:

    D = .5 * Cd * r * A * Vt^2

    D = Drag (Fd)

    Cd = Drag Coefficient (Bullet = 0.295)

    r(rho) = Gas Density (Air at sea level = 1.225 kg/m3)

    A = Cross-sectional area (Circles; A = Pi * r^2)

    Vt = Terminal Velocity (m/s^2)

    When I calculate this I get a value, I think is is N(Newtons).

    Since I am a greeny on physics I almost have no idea of what I am doing.

    Please be gentle. <img src="smileys/smiley9.gif" border="0" align="middle" />

    So how would I go about inplementing this to the Xpos and Ypos on the bullet. Which updates every 10 milliseconds. (In my example below)

    Any help is very very appriciated!

    Please explain like I was a 5 year old. <img src="smileys/smiley36.gif" border="0" align="middle" />

    According to this:

    en.wikipedia.org/wiki/External_ballistics

    <font color=blue>Drag or the air resistance decelerates the projectile with a force proportional to the square of the velocity.</font>

    Im not sure about this...

    Here is my file:

    web.comhem.se/~u54025770/ballistic_test.rar

    /MJOne

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here is a working example:

    http://dl.dropbox.com/u/5426011/examples%208/projectle_drag.cap

    But since you said you're new to physics I'd recommend using the physics behavior which will take care of most of the calculations for you.

    http://dl.dropbox.com/u/5426011/examples%208/drag_with_physics.cap

    A few notes:

    Set linear damping to 0%.

    Set the world scale x and y to 3.125% for 32 pixels to be 1 meter.

    The mass property is actually the object density in kg/m^3.

    You already have the formula to calculate the drag force, just apply it to the object in the opposite direction as it's motion.

  • Thank you R0J0hound!!!

    Well I know, the thing is this, I am not going to do a platform side scrolling game. I was just using this format to see what happends and if I get it right.

    I am planning to do a top-down turn-based or plan-and-go game. And I want to simulate drag and bullet drop using a "height" variable within the bullet object to determine where on the body the bullet will hit etc...

    I have a penetration formula as well, I might be able to figure that one out or I might post it here for anyone with godly powers to help a puny mortal like myself to make it work. <img src="smileys/smiley2.gif" border="0" align="middle" />

    Thanks again for the example I'll check ?t out asap! <img src="smileys/smiley4.gif" border="0" align="middle" />

    /MJOne

  • Well I have looked at the example you made and I realize I have some reading to do. <img src="smileys/smiley8.gif" border="0" align="middle" />

    Is it possible to get a reading on the current speed and height(not using sprite.y) of the projectile at any given moment?

    Like so:

    always -> set text to "Speed: " & varSpeed & " m/s" & newline &

                                   "Height: " & varHeight & " meters"

    I respect if you don't have time nor want to waster any energy on a pointless peasant like me, but asking is not a crime yet.

    <img src="smileys/smiley17.gif" border="0" align="middle" /><img src="smileys/smiley4.gif" border="0" align="middle" /><img src="smileys/smiley36.gif" border="0" align="middle" /><img src="smileys/smiley2.gif" border="0" align="middle" />

    Not that im lazy or so but do you have any articles up your sleeve where I can read more about the formulas you are using, or point me in a general direction so I don't have to bother your superior intellect in the future.(We can hope) <img src="smileys/smiley2.gif" border="0" align="middle" />

    Anyways, thanks again R0J0hound!

    /MJOne

  • The speed can be calculated with:

    sqrt(Sprite('vx')^2 + Sprite('vy')^2)

    or with physics:

    sqrt(Sprite[Physics].VelocityX^2 + Sprite[Physics].VelocityY^2)

    Height is just the distance from the bottom of the screen:

    480-Sprite.Y

    Here are some resources:

    physicsclassroom.com/class/vectors

    en.wikipedia.org/wiki/Kinematics

    en.wikipedia.org/wiki/Projectile_motion

    en.wikipedia.org/wiki/Trajectory_of_a_projectile

    en.wikipedia.org/wiki/Euler_method

  • Thanks a mill R0j0!

    Now I have something to occupy myself with :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)