Projectiles / Parabola calculations

Started by
2 comments, last by freshcut 14 years, 7 months ago
Hi This is my first post to gamedev.net so if I'm breaking any rules let me know and I'll straighten up my act I have a problem where I am firing a projectile from a point (sx,sy) and the target point is fixed (tx,ty). vix is known and fixed aswell. Now I want to work out the initial Y velocity (viy). I'm aware of the simple equation for getting y over time (t) y = viy * t + 0.5 * g * t^2; but I was hoping for an almost as easy solution to getting viy with the variables known that I have said above. Thanks very much
Advertisement
I'm not sure of any other way other than this one, however...



If you know vix, sx, and tx, then you know that the time it takes for the projectile to make its course is t = (tx - sx) / vix. Then plug it into the previous equation and solve for viy (resulting in viy = -g*t/2).

<a href=">

[Edited by - _fastcall on September 14, 2009 10:43:07 PM]
I'm not sure I understand what it is you are trying to find.

If you are trying to calculate the initial y-velocity:
You shouldn't have to right? If you fire the projectile, you should know at which velocity it was shot.

If you are trying to find the final y-velocity:
Use Vf = V0 - g*t and plug in the final time for t.

If you are trying to calculate the velocity as a function of time:
You can do this using the same equation as before or you can try a different approach. Rather than simply plotting a parabola using your equation
y = viy * t + 0.5 * g * t^2
you could choose a time step dt and do the following:

float x, y, vx, vy, ax, ay, dt, v0x, v0y;dt = 0.01f;v0x = 10.0f;v0y = 10.0f;ay = -9.8f;// take a time stepvx += ax * dt;vy += ay * dt;x += vx * dt;y += vy * dt;


This method is a simplified version of Euler integration and will yield a similar result. Using this method, you could always know the velocity in the x and y direction through vx and vy.


If none of these are what you were looking for, then please clarify. :)
Thankyou for the responses guys fastcall your solution worked perfectly thankyou :)
now I just need to work out how to do this when the start and end points are not have the same y value
If you have any more nibbles of genius I'd love for you to share them!

This topic is closed to new replies.

Advertisement