What are the formulas which represent the horizontal and vertical displacement of an arrow in flight (as well as it angle)? I would like to make sure that I take into consideration the arrow's fluid dynamics and center of gravity.
|
|
I actually answered this in your other question, but since this one is here, this is the place to do it cleanly on its own. What you are asking is the trajectory problem. First, consider it neglecting air friction. For an initial velocity v0 and angle a
for velocities as a function of time:
You need a reality check if you think you are going to handle instability, tumbling, or anything like that. You don't have the math for it, and it will take years to get it right, as well as massive amounts of CPU you don't want to devote in a game. You can try to fake that if you like. But if you want somewhat realistic slowing down of the projectile, that's relatively easy.
The coefficient c is a small number, and friction will tend to slow down the projectile so it always operates in the opposite sign of the moving projectile. You need the direction of the projectile, which is the vector:
but this is scaled according to the velocity. If you want to apply a negative acceleration, first compute the magnitude (already computed as v above) Now you can generate a vector 1 unit long in the direction of the projectile:
to apply the acceleration in reverse:
This will have the effect of slowing down the projectile and making it fall short of what it would do with no air friction. the higher your constant c, the shorter the trajectory. If you have wind, then just add to vx in your 2d game, in either + or - direction. If you really want to show the projectile tumbling once it moves slowly enough, ask another question, but that will be a discussion of how to fake it, not how to do the real physics. If you want to see just what you are getting yourself in for with simulating the drag on a projectile, this should be a survey paper that will show you the different approaches out there. http://raphael.mit.edu/peraire/SequeiraWillisPeraire.pdf |
|||||||
|
|
the simplest form you can simulate it is to use two weights connected to each other with a spring, resembeling head and tail of the arrow. and you have to just give the following object a little more thrust that the heading one to cause the arrow move like a real one, it just needs some tuning before it get's well, but it'll create a realistic movement. you can also make some diffrences for other parameters of head and tail weights, for example tail object has more air friction than the head one. |
|||||
|