POV-Ray : Newsgroups : povray.general : Particles 101 : Re: Particles 101 Server Time
19 Nov 2024 09:40:37 EST (-0500)
  Re: Particles 101  
From: Apache
Date: 21 Mar 2002 23:07:09
Message: <3c9aaded$1@news.povray.org>
You're using the (in)famous and forward Euler algorithm, which is very easy
to implement. This algorithm can become instable in some cases (like in your
case).

The following piece of code should make your system a bit more stable.
Increasing the steps per frame and decreasing the step size will make the
simulation slower, but more precise and stable. The damp factor eats away a
very small piece of the velocity at every time step. The more it eats away
(by lowering the damp factor), the more stable the system will be and the
faster the particles loose velocity.

/////////////// code snippet ///////////////
#declare stepsPerFrame = 100;
#declare stepSize = 0.01;
#declare dampFactor = 0.99;

#while (step < stepsPerFrame)
  #declare force1 = force1 + stepsize * vnormalize(pos2-pos1) * ((BigG *
mass1 * mass2) / vlength(pos2-pos1)^2);
  #declare velocity1 = velocity1 * dampFactor + force1;  //first leap of
faith
  #declare pos1 = pos1 + velocity1 * stepSize;  //second leap of faith
  #declare step = step + 1;
#end
/////////////// end of code snippet ///////////////
--
Apache
http://geitenkaas.dns2go.com/experiments/
apa### [at] yahoocom


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.