|
|
The typical question... :-)
I've got to clean it up a little before I make it
available, and I'm still tweaking on the thresholds
for the electrostatic repulsion. If I don't limit the forces
acting on a node, they squirm about way too much,
and it takes more iterations till it reaches a stable
state. If I use too low values, it just takes forever.
I need to find a simple way of refining the threshold
on the fly.
Also, I mean hey, your Christoph Hormann, you're
the one coding with springs all the time, aren't you?
Here's the momentary snippet:
//This loop calculates forces
#declare A_Counter = 0;
#while ( A_Counter < Sphere_Nodes-1 )
#declare B_Counter = A_Counter+1;
#while ( B_Counter < Sphere_Nodes )
#declare
Act_Dir=vnormalize(Sphere_Node[A_Counter]-Sphere_Node[B_Counter]);
#declare This_Force=1/ pow(
vlength(Sphere_Node[A_Counter]-Sphere_Node[B_Counter]),2);
#declare Force[A_Counter]=Force[A_Counter]+(Act_Dir*This_Force);
#declare Force[B_Counter]=Force[B_Counter]-(Act_Dir*This_Force);
#declare B_Counter = B_Counter + 1;
#end
#declare A_Counter = A_Counter + 1;
#end
//This one adds them to the positions
#declare Counter=0;
#while (Counter < Sphere_Nodes)
#if (vlength(Force[Counter])>Sphere_Force_Threshold)
#declare
Force[Counter]=vnormalize(Force[Counter])*Sphere_Force_Threshold;
#end
#declare
Sphere_Node[Counter]=vnormalize(Sphere_Node[Counter]+Force[Counter])*Sphere_
Radius;
#declare Counter=Counter+1;
#end
Sphere_Node is the array which holds the positions, and some declarations
should be pretty self-explanatory when checking the code...
--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
> Nice. Code?
Post a reply to this message
|
|