OCDots

Shake'em like nobody's watching

How it works

OCDots simulates Coulomb's forces between charged points and between a charged wire polygon and charged points.

You can install OCDots with npm and run it in your browser or with node.

This project was created to generate somewhat evenly distributed points inside of a polygon. It ended up being much more interesting than expected.

Point to point forces are directly proportional to their charges and masses, and inversely proportional to the square of the distance between them.

| F | = k c | q 1 q 2 | r 2

Polygon to point forces are the sum of forces for each wire segment that composes a polygon. Parallel $(E_x)$ and perpendicular $(E_y)$ electric fields can be easily computed (and tricky to implement) when described by the angles between the pont and vertex $a (θ_a)$, the vertex $b (θ_b)$ and the normal from the point to the line $(y)$. For OCDots, the points are always repelled from the walls even when they have negative charges. E x = kλ y [ cos θ b cos θ a ] E y = kλ y [ sin θ b sin θ a ]

Wire to point forces are very well described in this paper

Base Force is the variable that controls the overall force between elements. Drag linearly reduces the momentum at each time step. While Viscosity exponentially reduces the momentum transfer when the resulting force is too high. Max Momentum clips the momentum at each time step and also sets the initial boundary for the Viscosity momentum decay.

It's possible to set the mass and charge for each point, that will affect the final force and also the final velocity for given momentum.

Go on and shake'em!