POV-Ray : Newsgroups : povray.binaries.animations : Re: Point distribution on sphere (3 Attach.: 574, 378 & 396 kb) : Re: Point distribution on sphere (3 Attach.: 574, 378 & 396 kb) Server Time
19 Jul 2024 15:13:07 EDT (-0400)
  Re: Point distribution on sphere (3 Attach.: 574, 378 & 396 kb)  
From: Tim Nikias
Date: 31 Aug 2002 11:44:51
Message: <3d70e473$1@news.povray.org>
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

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