Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Projectile Motion

Tags:

c#

physics

I've scored the internet for sources and have found a lot of useful information, but they are math sites trying to tell me how to solve what angle an object has to be at to reach y location. However, I'm trying to run a simulation, and haven't found any solid equations that can be implemented to code to simulate a parabolic curve. Can those with some knowledge of physics help me on this?

like image 272
Dominic K Avatar asked Mar 20 '10 00:03

Dominic K


People also ask

What is the importance of learning projectile motion?

Understanding projectile motion is important to many engineering designs. Any engineered design that includes a projectile, an object in motion close to the Earth's surface subject to gravitational acceleration, requires an understanding of the physics involved in projectile motion.


1 Answers

While Benny's answer is good, especially in its generality, you can solve your problem exactly rather than using finite integration steps. The equation you want is:

s = u*t + 0.5*a*t^2;

Look here for an explanation of where this comes from.

Here s is the displacement, u is the initial speed, a is the acceleration and t is time. This equation is only 1 dimensional, but can be easily used for your problem. All you need to do is split the motion of your projectile into two components: one parallel to your acceleration and one perpendicular. If we let Sx describe the displacement in the x direction and Sy the displacement in the y direction we get:

Sx = Ux*t + 0.5*Ax*t; 
Sy = Uy*t + 0.5*Ay*t;

Now in your particular example Ax is 0 as the only acceleration is due to gravity, which is in the y direction, ie Ay = -g. The minus comes from the fact that gravity will be acting in the opposite direction to the original motion of the object. Ux and Uy come from simple trigonometry:

Ux = U*cos(angle);
Uy = U*sin(angle);

Putting this all together you get two equations describing where the projectile will be at a time t after being launched, relative to its starting position:

Sx = U*cos(angle)*t;
Sy = U*sin(angle)*t - 0.5*g*t^2;
like image 145
pheelicks Avatar answered Sep 29 '22 15:09

pheelicks