There isn’t necessarily any error. In simulations like this, using discrete timesteps always produces inaccurate results. You should be able to improve the accuracy by using smaller timesteps. (Mathematically, I think that as you let the timestep go to zero, the change in speed will go as the timestep squared, so it will vanish in the limit.)

Beyond that, more sophisticated integration methods are possible. What you are using is known as Euler integration, and is a simple but not particularly accurate method. You could upgrade to the midpoint method, or go all out with RK4. (Those links are to Wikipedia articles that discuss the methods in the context of general differential equations. You can probably find articles specialized to game physics simulations with a little googling.)

hi,

i try to build a simulation of an object in 3d space.

the object is point object with properties like this:

p : current position of an object.

v : current velocity of an object.

f : current force applied on an object.

m : object’s mass (1 kg)

dt : time elapsed since previous step

start condition:

v = (0, 0, 10)

p = (50, 0, 0)

at every simulation step (about 0.1 sec) the following calculations are made:

dt = GetTimeSinceLastStep()

f = CalculateForce()

v = v + (f / m) * dt

p = p + v * dt

the function CalculateForce calculates the current force at every step.

let’s assume that this function always return force in zx plane, perpendicular to the current velocity toward (0, 0, 0).

in such case, object suppose to perform circular motion with constant speed about the origin in zx plane. but here is my problem:

[(f/m) * dt] vector (that added to current velocity) will always have some length. so after addition it to v, the new v vector will be longer than the previous one (hypotenuse is always greater than two other sides in triangle).

so in my simulation the object always increase it’s speed and instead of circular motion i have a spiral one.

where is an error ???????

thanx in advance