# Basic Kinematics confusion

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

## 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 on other sites
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 on other sites
Sorry for the double post.

And thank you. I wasn't sure if I was going about it the right way.

##### 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 27
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634100
• Total Posts
3015527
×