Jump to content
  • Advertisement
Sign in to follow this  
rajesh msen

Projectile Range equation

This topic is 3058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi to all guys i am not good in physics and trigonometric I tried to do a projectile system.My launch point is higher than target point.I know the velocity v, target_distance d, gravity g,Launch_height_y y0.I added a link that shows the equation.I tried my own but not solved the equation.Please some one help me.Thanks in advance. d = 30,v = 22 , g = 9.8 ,y0 = 2 I wants to find the theta(angle)

Share this post


Link to post
Share on other sites
Advertisement
Ideally, solve for theta: http://en.wikipedia.org/wiki/Range_of_a_projectile
If you're going for an AI of some sort, (like for a 2D tank game?) you can just approximate it by assuming the ground is flat:
theta = (1/2)*arcsin(d*g/(v^2))
If you want slightly better accuracy, you can try adding to theta if the target is lower and subtracting from theta if the target is higher. You can also do this iteratively to get an increasingly accurate answer.
-G

Share this post


Link to post
Share on other sites
If this is for the AI in a game somewhat like Worms etc, then I think one approach is to generate a set number of random angles, simulate the projectile path for each one of those, and pick the one that gets the closest to the target. Then to increase the difficulty level of your AI opponent, you simply pick more random angles simulating more projectile paths.

This makes the game easily have a varying diffulty level, as well as making it harder for the computer AI to get you when it would be harder for the human player to get you.
Note also, that if you wanted to later add additional forces such as wind or air-resistance, this would easily be added to a system such as the above, whereas solving a formula for the angle would get increasingly difficult if you added more forces.

This may all not be relevant at all for what you're doing, so if I'm way off base here just ignore this. I also realise that not everyone posting on this site is working on a game.

Share this post


Link to post
Share on other sites
After much deliberation on the problem, I think it may be impossible to derive an exact solution for theta. This really annoys me.

For the record, I think I distilled the equation down to:
((d*d*g)/(v*v)) - y0 = y0*cos(theta)+d*sin(theta)

My TI-89 Titanium calculator can't get further with that either :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!