- #1

- 1

- 0

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 = (0, 0, 0)

dt = 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 (according to Pythagoras law) the new v vector will be longer than the previous one.

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

where is an error ???????

thanx in advance :)

the new