Projectiles / Parabola calculations
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
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]
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:
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. :)
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. :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement