I'm attempting to make a tank game in java in the vein of Scorched earth or Pocket Tanks, in that the user defines the angle and velocity of the projectile. I have looked over the internet for a way to implement wind speed into our projectile system. How do you add wind speed to projectile motion?
My program calculates X-Acceleration and Y-Acceleration of velocity, as well as taking to account the 开发者_如何学JAVAmaximum height reached, the total time it takes to reach the final point, and the angle of the projectile launched.
How do you add wind speed to projectile motion?
Try using a drag force = A * |Δv| * Δv * (surface area) + B * Δv * surface area, where Δv = (wind velocity) - (projectile velocity), and add it to the other forces in your simulation. (and then use Newton's law (ΣF = ma) to compute acceleration)
Note that the surface area is an effective area exposed to the wind. If your projectile is disc-shaped, for instance, there will be a very high drag force if the wind is blowing at the face of the disc, whereas there will be a low drag force if the wind is blowing across the disc.
Note also that this does not include drag torque (forces applied at different points of the projectile causing a nonzero net torque, and hence a change in the projectile's angular momentum) e.g. on a windmill or a falling maple seed. That's probably a lot more difficult to model than drag force.
To keep it simple How about adding or subtracting horizontal velocity based on the direction the wind is coming from compared to the direction the projectile is traveling.
if it is a tail wind it will add a certain ammount of velocity over time until it reaches the max velocity that the tail wind can contribute to the projectile itself, and the same is almost true for head wind except that at a certain angles with certian horizontal speeds of projectile a head wind of high enough speed may reverse the horizontal velocity.
the longer the projectile is in the air the more time the wind has to work its magic.
Or instead of using a drag force, you can just implement a regular force. If your objects are all the same size and shape (cross secitonal shape), just pick an F and apply that force to your velocity calculations.
精彩评论