Jump to content
  • Advertisement
Sign in to follow this  
freshcut

Projectiles / Parabola calculations

This topic is 3291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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 step
vx += 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. :)

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!