# Basic Projectile Physics

1. Aug 26, 2007

### Blommestein

I'm trying to simulate a projectile launch like this ( http://galileo.phys.virginia.edu/classes/109N/more_stuff/Applets/ProjectileMotion/jarapplet.html ). I googled but the results aren't specific.

What would you set the x and y of an object when time ( t ) is updated, assuming you have these vars:

* angle ( a )
* velocity ( v )
* x0 ( initial x )
* y0 (initial y)
* Not sure if necessary, but if so gravity (g)

_____________________

Also, given a projectile at its initial position'(x0, y0) and angle 'a', how can I solve for the velocity (v) to make it pass through a point (x, y)?

Thanks.

2. Aug 26, 2007

### hotvette

3. Aug 26, 2007

### rootX

you need to know vectors, in order to make those like simulations.
you making it in java?!
I would be interested working *against* you! -- don't have anything else to do

Last edited: Aug 26, 2007
4. Aug 26, 2007

### Blommestein

Thanks for the link. This is for computer programming by the way, not a physics course. :)

So is this it then?

x = vel*cos(θ)*t
y = -½ g*t^2 + vel*sin(θ)*t

Any idea of a formula for finding the second part?

Thanks!
Thanks for the offer, but I just need to find this one thing and then apply it to a bigger school project I am working on. :)

5. Aug 26, 2007

### rootX

Last edited: Aug 26, 2007
6. Aug 26, 2007

### rootX

for the second part, you need to solve your parabolic equation, i guess.

so make it like y=..x

and then solve it

7. Aug 26, 2007

### Blommestein

Don't have time to open your project right now, but Ill take a look at it later.

It's a 2D platformer that resembles gameplay similar to sonic. It's beign developed in both Java (as an applet) and Flash (ActionScript 3, as a swf).

__________

Okay the projectile launch seems pretty realistic. Here's how I have it:

int xzero = obj.x;
int yzero = obj.y;
int t = 0;
int vel = 100;
int theta = 45;

On thread call (every 1/35 of a second):

t += 1/35;
obj.x = vel*Math.cos(theta*(Math.PI/180))*t+xzero;
obj.y = 16*t*t -vel*t*Math.sin(theta*Math.PI/180)+yzero;

But now I'd like to calculate the velocity required to hit point x2,y2 from initial point xzero, yzero with angle 45. How would I do this?

Appreciate all the help.

8. Aug 26, 2007

### rootX

in that original equation,
first isolate t in the x equation {x = x0 + vel*cos(θ)*t}

and substitute t value into the y equation
and then you can isolate v..

9. Aug 26, 2007

### Blommestein

I'm a little confused. If I were to do that (isolate velocity in the obj.y assignment), I'd need to know what the obj.y equals, and to calculate that I need the velocity, so it's like an endless loop.

10. Aug 26, 2007

### rootX

no y equals to y2
and x equals to x2,
in those equations

11. Aug 26, 2007

### Blommestein

Oh, of course, that's genius! Ill try it out. :)

12. Aug 26, 2007

### rootX

I guess you would also need mathematical co-ordinates, as computer screen is in pixels lol

>(evil smile)<

13. Aug 26, 2007

### Blommestein

Okay I got this far:

x = x0 + vel * cos(ang)*t
t = x/x0 + vel * cos(ang)
y = y0 + 16 * t^2 - vel * t * sin(ang)
y = y0 + 16 * (x/x0 + vel * cos(ang))^2 - vel * (x/x0 + vel * cos(ang)) * sin(ang)
vel = ?

Now I need to isolate vel, but I'm not sure exactly how.

14. Aug 26, 2007

### rootX

just a sec.

if you are free, can you define what you are trying to do here?

Last edited: Aug 26, 2007
15. Aug 26, 2007

### rootX

$$\left| x\right| \,\sqrt{\frac{g}{x-y}}$$

or, substitude x-x0 for x, if you want from x0,y0 point; also add "y0" to the y equation

P.S. check this for like two cases

Last edited: Aug 26, 2007