How Do You Calculate Projectile Trajectory in Physics Simulations?

  • Thread starter Thread starter Blommestein
  • Start date Start date
  • Tags Tags
    Physics Projectile
Click For Summary

Homework Help Overview

The discussion revolves around simulating projectile motion in a programming context, specifically how to calculate the trajectory of a projectile given initial conditions such as angle, velocity, and position. Participants explore the mathematical relationships governing projectile motion and seek to implement these in a programming environment.

Discussion Character

  • Exploratory, Mathematical reasoning, Problem interpretation

Approaches and Questions Raised

  • Participants discuss how to update the x and y coordinates of a projectile over time using variables like angle, velocity, and gravity. There are inquiries about deriving the necessary velocity to reach a specific point given initial conditions. Some participants suggest isolating variables in equations to solve for unknowns.

Discussion Status

The conversation is active, with participants sharing their current implementations and seeking clarification on mathematical relationships. Some guidance has been offered regarding isolating variables in equations, but there is no explicit consensus on the best approach to calculate the required velocity for a projectile to hit a target point.

Contextual Notes

Participants mention constraints related to programming environments and the need to consider pixel coordinates in their simulations. There is also a reference to the project being part of a larger school assignment, indicating a focus on practical application rather than purely theoretical discussion.

Blommestein
Messages
6
Reaction score
0
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.
 
Physics news on Phys.org
Blommestein said:
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:
hotvette said:
Welcome to the forums!

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

https://www.physicsforums.com/showthread.php?t=93670

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.

>>What's the project about?

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..
 
rootX said:
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.
 
  • #10
no y equals to y2
and x equals to x2,
in those equations
 
  • #11
Oh, of course, that's genius! Ill try it out. :)
 
  • #12
I guess you would also need mathematical co-ordinates, as computer screen is in pixels lol

>(evil smile)<
 
  • #13
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
just a sec.

if you are free, can you define what you are trying to do here?
because I might help you coming up with an alternative solution
 
Last edited:
  • #15
[tex]\left| x\right| \,\sqrt{\frac{g}{x-y}}[/tex]

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:

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 53 ·
2
Replies
53
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
3
Views
4K
Replies
21
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
1
Views
2K
Replies
10
Views
4K
  • · Replies 27 ·
Replies
27
Views
3K