Jump to content
  • Advertisement
Sign in to follow this  
Knuckler

Basic Kinematics confusion

This topic is 3764 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

I tried to write a program to test my knowledge of kinematics. It does what I wanted it to do (somewhat), but the way it's implemented makes me wonder if I have the idea of kinematics down. What I was trying to do was have a single particle simulate the water of fountain. It has a initial velocity, it goes up for a while, then comes down due to gravity. I used the formula x = v0xt + (axt^2)/2 y = v0yt + (ayt^2)/2 I was under the impression that x and y in formula was "displacement" and I could "+=" (C++) the value to my game object's position. Doing this resulted int the particle shooting off the screen. If I just use "=", then I get the correct results, but that means my object can't have a initial position. I would post some code, but I'm at work at the moment.

Share this post


Link to post
Share on other sites
Advertisement
That formula describes the current position at t given an initial position, initial velocity, constant acceleration. It's full form is:

x = x0 + v0_x * t + (a_x * t^2) / 2.

And similarly for y.

So there are two ways for you to solve this:

1. Remember the intial position (x0), then add those values to the position every frame, as described in the function. This, however, does not allow for any sudden changes in velocity or acceleration as you're essentially recalculating the entire path every frame.

2. Update the position (as you first tried), but use:
x += v.x * dt
v.x += a.x * dt
where dt is the change in time since the previous update. Probably the best solution in the general case. Acceleration and velocity can now change as often as you'd like.

Share this post


Link to post
Share on other sites

This topic is 3764 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.

Guest
This topic is now closed to further replies.
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!