Jump to content
  • Advertisement
Sign in to follow this  
Knuckler

Basic Kinematics confusion

This topic is 3641 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
your equation is correct, don't use the += !
if you want an initial position, just use the full formula:

x = v0xt + (axt^2)/2 + x0
y = v0yt + (ayt^2)/2 + y0

cheers.

Share this post


Link to post
Share on other sites
There's a way to use the "+=" operator. It's simply less "efficient" and requires one more variable( actually, no... ) and more computing( actually one addition per equation )

So, computing x(t+dt) yields:

x(t+dt) = vox.(t+dt) + (ax.(t+dt)^2)/2
<=> x(t+dt) = vox.t + vox.dt + (ax.t^2)/2 + ax(t.dt+(dt^2)/2)

=> x(t+dt) - x(t) = vox.dt + ax.t.dt + (ax.dt^2)/2
<=> x(t+dt) = x(t) + vox.t + ax.t.dt + (ax.dt^2)/2

or using operator+=

x += vox.dt + ax.t.dt + (ax.dt^2)/2
<=> x += vox.dt + ax.dt( t + dt/2 )
<=> x += ( vox + ax( t + dt/2 ) )dt

You'll need the initial position only once.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!