ElectroStatic-Repulsion-Macro

by Tim Nikias Wenclawiak

Last update: 31.08.03

homepage: www.nolights.de


Index

Introduction

Introduction

First of all, the typical stuff: Credit where Credit is due

Please make sure that, when you're using these macros, my name and perhaps my homepage is mentioned somewhere in the credits, even if you're using modified versions of the macros. That is mostly more or less a moral issue. For people who actually make money in any way aided by these macros, I'd like to receive a note in which way, and would be happy to have a look at it. But since I don't expect anyone will actually make much money with these macros, but more with their own ideas, I don't want to have people think I'd want money for this. I don't.
As a general rule of thumb (and you may easily apply this to works of others as well):
give credit where you feel credit is due.

What's the Macro for?

The Macro takes a given amount of "electrons" and places them on a spherical hull. Then, using repulstion forces, the electrons try to move away from each other, but are always constrained to the spherical hull. In effect, this is what electrostatic repulsion is all about, and you can read lots of it on the net once you've begun looking for it. Anyways, its use is simple: it provides an even distribution of a number of points on a sphere. I don't know how often you came across trying to do a disco-sphere, or a golf-ball, but this macro may make that job much easier. When using the spherical hull as actual hull around some other object, a pseudo-even distribution may be achieved when mapping the electrons onto the object. In the end, if you don't know what use an even distribution on a sphere has, well, then you won't probably need this anyway. :)

Finally


Macro Usage

The Macro is actually fairly simple to use. There are a few parameters you'll have to set first.

1. Amount of Electrons

This shouldn't be too difficult to grasp...

2. Radius of Sphere, and Center of Sphere

The Electrons' position will later be saved on a spherical hull. You may easily just supply the unit-sphere with 1 as Radius and <0,0,0> as center, but sometimes saving them to a different location from the beginning on may be useful.

3. Iterations

To calculate the forces and move the electrons, the macro requires a rather high amount of iterations. They won't parse all the way through when the following parameter is set to something other than zero, but I've found it useful to begin with 250 and move higher if needed.

4. Minimum-Force Interruption

In every iteration, the forces acting on the electrons are calculated. In a TOTALLY stable solution, this would be 0, but that's hardly ever reached. A visually pleasing solution is often found after about 300 to 400 iterations when leaving this parameter at 0, but sometimes some iterations less wouldn't harm either. For 50 electrons, the best force I've come across was about 0.5, and it rises with more electrons. You've got either experiment or just have patience.

5. Name of File (without ending)

The Macro will spit a file into the directory where the scene is run, with the ending ".esr". The main reason why you don't specify a whole filename with ending is because I've implemented a feature to ensure that already existing files won't be overwritten. If a file already exists, the Macro will add a number to the name, and count upwards until it reaches a name which isn't already there.

6. Name of Array

Inside the file, a 1D-array is saved with positions of the electrons. You may specify an array-name with which you can access the array after you've included the file.

7. Overwrite-Protection-Boolean

When set to 0, this feature is switched off and the macro will just overwrite existing files. When set to 1, it will avoid doing that by adding a number to the given filename.


Extras

As an extra, I've supplied Get_Min_Distance, a brute-force algorithm to find the closest distance between any two points in a 1D-Array. I've made use of this by using the calculated value as diameter for sphere placed at the electrons' positions, so that they won't intersect. That's basically its use.