# Basic Projectile Physics

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.

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.

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:
Welcome to the forums!

Check out Motion3c.pdf in the following link. That should help getting you thinking in the right direction.

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!
you making it in java?!
I would be interested working along with you! -- don't have anything else to do

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. :)

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

so make it like y=..x

and then solve it

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.

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..

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..

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.

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

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

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

>(evil smile)<

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.

just a sec.

if you are free, can you define what you are trying to do here?
$$\left| x\right| \,\sqrt{\frac{g}{x-y}}$$