Parabolic Projectile Trajectory

AI Thread Summary
Calculating the trajectory of a cannonball in a video game environment with only gravity acting on it is feasible using kinematic equations. The discussion highlights the importance of breaking down calculations into x, y, and z directions, particularly when shooting at a fixed angle like 45 degrees. The equation mentioned, distance = velocity x time + 0.5 x acceleration x time², serves as a foundational tool for these calculations. Proper rotation of the cannon can be achieved by pointing it directly at the target, and the vertical angle does not need to remain fixed. Overall, understanding these principles allows for precise targeting in the game design.
rcrumb
Messages
6
Reaction score
0
Hi,

Im currently working on a video game, and have come to an aspect that I'm very unsure about (I'm self taught in most of my game physics knowledge, so there are quite a few gaps). Let's say there is an environment with no features that act on objects except for gravity (or simply no wind resistance). I am shooting a cannonball from a specific x,y,z coordinate, and am trying to hit another x,y,z coordinate. The cannon is going to be at a consistent angle (lets say 45 degrees). Is there an equation that i could use, where starting from one x,y,z location, i could calculate the rotation, velocity, and gravity to hit the exact other x,y,z location? Is this calculation possible, or will I always get "just very close" to the ending x,y,z location?

Thanks.
 
Physics news on Phys.org
yes this calculation is possible. how do you want rotation and wind resistance to play a part? i suggest that since its a video game you neglect those.
 
there will be no wind resistance. however, in terms of rotation if my canon was located at (300,200,0) and i had two targets, one at (350,250,0) and the other at (150,150,0) i was wondering if there is also a way to calculate the proper rotation to hit each target (one at a time).
 
what do you mean proper rotation. the only part rotation has to play is friction with the air. and if you are saying there is already no air resistance what does your rotation matter?
 
If for the purposes of your game you want to say that a spin of 1 revolution per second causes a force of 1 Newton in a direction perpendicular to the motion of the cannon ball that is fine, but not consistent with your physics
 
oh sorry. i meant rotation of the canon itself (as if it were on a 360 degree swivel), so that it will point directly towards the next target. the ball will always follow a straight path to the target.
 
oh. yes then the equation is very solvable. you don't even have to keep your vertical angle fixed.
 
interesting, is there a specific name/equation for doing these types of calculations?
 
yeah they are all kinemetics equations.

distance = velocity x time + 0.5 x acceleration x time² is one i might start with.
how much physics background do you have?
 
  • #10
not much, I've studied and programmed velocity, acceleration, and gravitational force before, but that's about it.

in the distance equation, what does the 0.5 represent?
 
  • #11
thats a good question. i believe it is there because it is the time integral of at
 
  • #12
but with that equation that i gave you, you have to be sure to split up all of your calculations into x direction y direction and z direction. so if you shoot a cannonball at 45 degrees in the air and you want to figure out the distance it will travel in the x direction, you will need to use the initial speed in the x direction. so it would be vsin45.
 
  • #13
Also if you make all of those variables, you will have an infinite amount of solutions.
 
  • #14
very cool! thanks for all the help dacruick.
 
Back
Top