Ballistic Simulation Problem

For questions about using Classic.

Post » Mon Dec 05, 2011 4:47 pm

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:

http://www.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.

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.

According to this:
http://en.wikipedia.org/wiki/External_ballistics
Drag or the air resistance decelerates the projectile with a force proportional to the square of the velocity.

Im not sure about this...

Here is my file:
http://web.comhem.se/~u54025770/ballistic_test.rar

/MJOne MJOne2011-12-05 16:55:18
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Mon Dec 05, 2011 9:25 pm

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.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Dec 06, 2011 11:16 am

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.


Thanks again for the example I'll check t out asap!


/MJOne
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Tue Dec 06, 2011 11:43 am

Well I have looked at the example you made and I realize I have some reading to do.

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.


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)

Anyways, thanks again R0J0hound!

/MJOneMJOne2011-12-06 11:56:22
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Tue Dec 06, 2011 6:31 pm

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:
http://www.physicsclassroom.com/class/vectors/
http://en.wikipedia.org/wiki/Kinematics#Kinematics_of_constant_acceleration
http://en.wikipedia.org/wiki/Projectile_motion
http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
http://en.wikipedia.org/wiki/Euler_method
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Dec 06, 2011 6:55 pm

Thanks a mill R0j0!

Now I have something to occupy myself with :)
B
5
S
1
G
2
Posts: 28
Reputation: 806


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests