Balistics???

Started by
18 comments, last by asmcoder 14 years, 6 months ago
Hi, Could anyone please tell me how to determine every point in a projectile path, according to the angle and the power? I am trying to implement a firing system similar to the one used on Bowmaster prelude : http://www.lostvectors.com/prelude/ I have tried to google for it, I've found a lot of formulas and I cannot determine which one to use to solve the problem. Thanks. [Edited by - asmcoder on August 31, 2009 12:35:45 PM]
Advertisement
Your question makes no sense I'm afraid -- there are an infinite number of points in a path...

Perhaps you could explain in a little more detail?
There is the parametric equation method, or there is the iterative integration method. You can use either in a game but it depends on what your goal is.

Parametric form would look something like this:

x(t) = x0 + vx*ty(t) = y0 + vy*t + (ay*t*t)/2


where x0, y0 is your start position, vx,vy is your starting velocity, and ay is your gravity acceleration. t is the total elapsed time since firing the projectile.


Iterative integration form looks something like this:

once when you fire{  x = x0;  y = y0;}loop{  x += vx * dt;  y += vy * dt;  vy += ay * dt;}


where dt is a small amount of time that you want to approximate. For a really simple example, you run the loop once per visual frame of your game and set dt equal to the time between the last frame and the current frame.


This is just the most basic idea. There are other details that you will get to later as you start making the game more complex.


As for converting your angle/power to vx,vy, the simplest way is to do this:

vx = cos(angle) * power;vy = sin(angle) * power;


which is just a simple polar-to-cartesian coordinate conversion.
I have to object to the use of the word "power". You probably mean "initial speed".
Hi! Sorry for being unclear on my previous post.

I've made a little picture to describe the problem, it shows some diferent possibilities.

Known prameters before the launch of the projectile are: the starting point (x0, y0), the Initial Speed or Power(S) and the Angle (A).


What I want is a formula to make my projectile move (One step per frame) according to the path of the projectile.


Would realy apreciate your help.
Thanks.


EDIT: By "velocity" in the picture, I mean "initial speed" or "Power"... Sorry, my Physic skills are poor! :(


alvaro's point was simply to do with the definitions of some of the words you were using.

1. Velocity, v, is the rate of change of position. It is a vector.
2. Speed, v = ||v||, is the magnitude of the velocity vector.
3. Kinetic energy, K.E. = (1/2)m v2, is the amount of energy stored in the motion of the projectile.
4. Potential energy, is the energy stored due to the projectile's position in the gravitational field created by the earth. In this case, it is P.E.= m g h, where h is the height above the ground.
5. Total energy, E = K.E. + P.E., is the total energy of the projectile, and it remains constant.
6. Power is a rate of change of (some kind of) energy; it is the rate at which energy flows from one "energy storage reservoir" (e.g., kinetic energy) to another (e.g., gravitational potential energy). For another example: We often speak of the power of a car's engine; this refers (ideally) to the maximum rate at which it can increase the kinetic energy of the car.

So to summarize,
1. Velocity is "how fast" together with "in what direction."
2. Speed is just "how fast"
3. Kinetic energy is "how fast" together with "how massive."

[Edited by - Emergent on September 2, 2009 3:14:58 PM]
Cheers for the definitions! That would help for sure.

So, how am I going to implement the firing mechanisme as described on my previous post?

Thanks a lot.
Quote:Original post by asmcoder
Cheers for the definitions! That would help for sure.

So, how am I going to implement the firing mechanisme as described on my previous post?

Thanks a lot.


First, tell us what programming languange you're using for this. That will make it easier for us to give you a hand, and maybe someone's already got the code you're looking for :-)

(ps. to the mods: why the heck am I able to edit everyone's posts?)
if you want to work out positions as you go then you could do this:

Work out initial velocity (as a vector), store start position, store gravitational acceleration (lets say -10 (or (0, -10) as a vector) to keep things easy)

Initial state:
position = (0, 0)
velocity = (1, 1)

for the next update, work out how much time has passed since the previous update (lets say 0.5 seconds)

Move the projetile:
new_position = old_position + velocity*timePassed
(0.5, 0.5) = (0, 0) + (1, 1)*0.5;
now add gravitational acceleration to the old velocity
new_velocity = old_velocity + acceleration*timePassed
(1, -4) = (1, 1) + (0, -10)*0.5

new state is then
position (0.5, 0.5)
velocity (1, -4)

Do that each time to generate a new position.

If you want to precalclate each point then working it out from a forumla would probably be better but if you just want to move a projetile around then the above is simple (and allows you to add additional forces to it quite easily).

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

Thanks for the help.

You've neglected the Angle in you calculs, which I believe it's the most important factor to determine the path of the projectile (Position of projectile per frames).

I think the magic word here is "Arcing projectile algo" , I've found this which I think it can help:

http://www.physics.buffalo.edu/phy410-505-2008/chapter2/ch2-lec1.pdf

I would try to see if that works for me, meanwhile, I'll be very interested if somebody could provide me with a working way to solve this. :)

Thanks.

This topic is closed to new replies.

Advertisement