POV-Ray : Newsgroups : povray.general : Particles 101 : Re: Particles 101 Server Time
6 Aug 2024 12:16:50 EDT (-0400)
  Re: Particles 101  
From: Mark Hanford
Date: 25 Mar 2002 12:44:27
Message: <3c9f61fb@news.povray.org>
I'll try that damping, although at the moment, I think there are more
fundamental issues with my system...

--

Mark Hanford
http://www.mrhanford.com/povray


"Apache" <apa### [at] yahoocom> wrote in message
news: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.