Sunday, January 19, 2025

Acute Angle Detection : Geometrical, Mechanical or Kernel

The corners in our Dynamic Foam are like gates in an electronic circuit or valves in a 'classical' flow system. When the angle is Acute, smaller then 90 degrees (< 90°), the flow is cut-off. 

This is the main rule that regulates our system and generates structure (closed-knots) like Leonardo's bridge.



So in our Foam, Voronoi-mesh, we need to detect the Acute angles ... 


... were the angles pass the 90° mark:

I have been investigating 3 methods to solve our Acute Angle Detection:

I. Geometric

There are 3 geometrical methods to calculate the angles when you have the 3 reference points, you can check it all here: https://www.wikihow.com/Calculate-Angles



II. Mechanical

The mechanical method uses a perpendicular placed marker with:
length = distance from pivot-point.

You can test it with the Shadertoy example:
Instead of a perpendicular-stripe you can also use a circle and do a boolean cut ...


... and for 3D use a Sphere with a plane to do the cut.

Technically in the program we can:
A. Implement the calculation at each edge-end.
B. Do the calculation once and use it as a stencil to 'print' it at each edge-end.

III. Kernel

A pixel 'kernel' that does a 'numbers' match-check.

IXIXIXIXIXI
IXIXIOIXIXI
IXIOIXIOIXI
IOIXIXIXIOI
IXIXIXIXIXI

Although I haven't throught this through yet. ๐Ÿ˜

To be continued ...

Acuteness Cells

 A new ’slightly’ different approach that might be a lot easier to process the Dynamic Foam:

Instead of doing a search along the edges, where the acute angles (sharp < 90°) are the regulators ... we might get the same result by calculating the acute angles and ‘mark' the cells. Similar to Conways Game of Life.

The idea is that a tree search is equivalent to counting the surrounding cells, in both cases the same 'effect of the sharp corners’ in the foam is sensed and applied.

I. Previous models : Monte Carlo - and Local Edge Search

• Find Sharp-angels and mark the corners.

• Unique tree-search for each edge to define the Weight of each cell edge.

• Sum of all weights = > New Pressure.

• Balance out cells based on their new pressures and draw new Voronoi-Layout, with Power-Voronoi-tracking-cells*.


--

II. Future model : Acute Angles Counting / Sub Cells

• Detect Acute Angles

• Acuteness : Count Acute-angels per cell (0, 1, 2, 3)

• Color the whole cells depending on the acuteness value.

• Sum of all marked adjacent Sub-cells => New Pressure.

• Balance out cells based on their new pressures.

Like in Game of Live.

————

Shadertoy tests:


• Sharp acute angles (<90°) are marked white.
• Based on N° of interior acute angles (1, 2, 3) the Voronoi cells change light yellow to dark orange.
• Blue Voronoi cells have no acute angles.


Voronoi Cell Volume is regulated by number of 'adjacent' acute angles.
• Acuteness = acute angles (<90°) per Cell
• Cell Volume is regulated by Acutess: (0,1) increase <-> (2,3) decrease
• Cell color = Acuteness: 0 = White, 1= Blue, 2 = Red, 3 = Black

The relation to GoL is that in GoL we count the 'living' adjacent cells to define if a cell lives (increases) or dies (decreases). Here we count the number of acute-angles ‘around’ each cell, 

There are only 4 ‘acuteness’ levels possible: 0,1,2,3

When it's (0,1) the Volume of the cell increase / lives <-> (2,3) the cell decrease / dies. 

Like in GoL cells ‘live’ or ‘die’ depending on the organisation of its neigibours.

There's a ‘physical’ and a 'mental' part to this:

• Physical: circular-particles that can increase or decrease, and push each other away. The centers of these circular-particles are used as the Centroids of the Voronoi mesh on top of it. You can see cicular they are light transparent black.

• Mental: On top of the physical circular-particles is a Voronoi-mesh, that uses the centers of those circular-particles as centroid. Next for each Voronoi-cell we calculate the number of acute angles, and use these values to color the cells. We also feed this result to the 'physical' circular-particles, so they know how much they need to increase or decrease. Noter, we set an upper and lower bound, otherwise the sim explodes.

Result: The physical circular-particles change in size. -> They pushed each other. -> New Voronoi layout. -> New acuteness values for the cells. -> The physical circular-particles change in size -> Et c’est parti! -> C’est la vie! ๐Ÿ˜€

PS Blue noise distribution of the particles is for a ‘natural’ random distribution at the start, instead of Poison distribution. If we use for instance an symmetric array that gives us all clean tiled Voronoi cells with zero acute angles, then they all would decrease into a hole, it would be like starting GoL off with a block of black cells that all die.


--
The plan is now to use Voronoi-Tracking and introduce:

*Power-Voronoi-tracking-cells

The idea to adjust 'relatively' the Voronoi-particle-tracking pixels (texels) 
related to the Volume value of the particles to adjust 
the size of the tracking Voronoi Cells.

To be continued ...

Currents in the Edges Table

Overview table with the different approaches to solve the Dynamic Foam with Currents in the edges: Dynamic Foam and VoroX with a Dual Voronoi-Delaunay mesh, and also the suggestions for a new version with Weighted Voronoi, and a marching method to search along the edges.


The top layer has 3 methods to search the pressure distribution in the edges of the Voronoi Mesh, but it doesn’t change the Voronoi Mesh physically. 

I. Particles move ‘live’ along the Edges, this is used in the Dynamic Foam program made by Nick McDo: https://github.com/weigert/DynamicFoam/wiki/System-Dynamics

II. Use a search in the Geomatric matrix using Markov Chains like how Googles Page Rank works, this used in VoroX made by Benoรฎt L.t: https://github.com/blegat/VoroX.jl

III. This is a new suggestion to use short local search by marching the edges and being blocked when running into a sharp angle.

This layer is about finding out the weight of each edge.

——

B. This next layers are how we apply the results from A to the mesh(es) and physically change the Voronoi (and Delaunay) Mesh and get a new Voronoi lay-out. With two columns:

Green: Dual Voronoi-Delaunay mesh: particles or weights on the Voronoi Mesh makes it’s dual-Delaunay edges contract, and shifting the centroids of the Voronoi Cells.

Orange: Weighted Voronoi: the total weights of a the Edges of a Voronoi cell change it’s Sphere size (pressure) and the Spere-packing changes due to each Spere new size.

——

Some diagrams regarding a Marching model.


A couple of short walks done in the direction of each connected edge to measure the weight of each edge.


Tuesday, September 3, 2024

Numerical Solution to Strings Theory. ๐Ÿ˜‡

Dynamic Foam is the Numerical solution to solve String Theory vs Analytically. Simply because Voronoi already has the basic String-fibers, read edges. 


They only need be tied into Knots. ๐Ÿชข


 Voronoi ☯ Delaunay 

Kaluza-Klein theories (an important precursor to string theory) shows how you can get Electro-Magnetism from Einstein's GR if you assume an extra (5th) dimension which is a circle (Torus). A particle moving around this circle (i.e. with momentum in the 5th dimension) appears to a 4-dimensional observer (us) to have electric charge. It is quantised because the circle has a finite size.






*The Red cells contain a sharp < 90° angle where the distribution
of the pressure (flow) in the edges is cut-off.

-
Short Recap:

Markov-Chains in Voro-X calculate the pressure-flow for each edge based on the number of connections. It's like Google’s Page-rank looking for connected websites, as a result we get for each Voronoi-edge a value.


First we check the gates/angles if the are open or closed, based on the 90° angle rule:
> 90° is open
< 90° is closed


Next we calculate the connections:
(A) is open to (B) and (C)
(B) is open to (A) but closed to (C)
(C) is open to (A) but closed to (B)


We use a local connection-tree to calculate the value for each individual edge.


These values make their dual Delaunay-edges contract or expand, 
and as a result we get cells shrink or expand.

Sunday, July 28, 2024

Oscillating Particles Simulator

 A couple of months ago I got in touch with David Schoemehl who had a boids-simulator, and we turned it into an Oscillating Particles Simulator to test the idea of having a Voronoi-pattern self-emerge out of a random group of vibrating particles that expand- and contract Space.

https://gitlab.com/niceeffort/oscillating_particles


To run the program: 
• Download the GODOT Game engine: https://godotengine.org/
• Open the 'project.godot' file in the folder you can download from GitLab -> Code (blue button top right)
• Run the program via the 'clapperboard-play-button' at the top right.


---

We did managed to get Voronoi-ish patterns (see videos): 




---

Small recap: the idea was to have particles that vibrated (expand/contract) between size 1 -> 10 


When they expand they push other particles away, and when they contract they pull other particles towards them. (Attraction-Repulsion Forces)

The simulation would begin with a random distribution and the idea was that particles with the same timing would align, form groups and a Voronoi-Pattern would self-emerge.


The idea is similar to the Kuramoto Model, think of metronomes placed on a rolling plate that start synchronise:

“A mathematical model used in describing synchronization. More specifically, it is a model for the behavior of a large set of coupled oscillators.”



The difference with my model was that in the Kuramoto model particles adjust their period to each other, while mine they keep their fixed period*.

————

The first results didn’t produce the desired result. Particles would contract into Voronoi-cells but each time they expanded, and contracted-back different new groups were formed. So the Voronoi-patterns weren't stable. 


To solve this we added two extra features:

1. Groups

The first feature made it possible to multiple groups of particles of which we can adjust: size, vibration rhythm and give each group a percentage of the total amount of particles. 


a) Large group (72%) of small Blue particles ; b) Small group (20%) of large White particles; c) Small group (8%) in-between sized Red particles.

Why multiple sized groups?

In the beginning Space is a dense medium wherein oscillations emerge randomly.


The first wave has all the freedom and can cover wider areas.
Second waves are limited by the pressure caused the first wave and covers smaller areas.



2. Random

The second feature was to have the option to have all particles vibrate randomly or in synchrony.


————————————

These two new features lead to two discoveries:

1. Buffers

We used groups of particles with different sizes of particles:
• Small Blue ones: vibrating-size between 2 - 3 (72%)
• Larger White ones, vibrating-size 3 - 7 (20%)

Because of Granular Convection the larger particles are pushed outside the group of small particles ...


… and form a Buffer between the cells:


These buffers prevent the smaller particles to contract each time into different cells, as a result we get stable cells.

———

2. Balancing vs Colliding Cells


In the simulation above with the buffers, the Blue-particles vibrate Random between 2 - 3

As a result one half the Blue-particles are expanding, while the others are contracting, and we get two vibration rhythms and a fluctuation between the two.

Both halfs of the group of Blue-particles keep each other in balance:

One is contracting vs the other is expanding.

The problem with this balancing-act is that it flattens out the pressure in the simulation. Everything wobbles and there’s no pressure generated in the edges, which is needed for my concept of a Dynamic Foam:

were there are pressure-currents in the edges that are cut-off when angles are < 90°:


and circuits are formed.


It made us realise that we needed to get the cells moving in sync and have them collide simultaneously, so we have each time a pressure peak in the edges, and pressure has to spread out through the edges, perpendicular to the cells. 

And this is exactly what happens when we Turn-off Random, see how the cells now collide:


There’s a tipping point above 1200 particles in this example, where the pressure is so high in the edges that we get 'crawler-errors', where the program 'mitigates' the overlapping particles.

It shows that pressure has to go somewhere (sideways through the edges).

———

Conclusion:

 We can get stable Voronoi-patterns, but the idea of keeping their fixed period is wrong for my project, particles should sync like the metronomes in the Kuramoto-model.

Two differences between the Kumamoto model are the second group of larger Buffer-particles that stabilise the cells and the Attraction-Repulsion Forces. 

When turning Random Off we get pressurised edges thanks to the colliding Voronoi-cells vs when Random is turned On, then the cells balance each other out.

The problem moving forward for this project are those ‘crawler-errors’ that don’t distribute the pressure correctly through the edges, so we'll need to shift back to a mesh approach or a shader ... 

To be continued.


————————————


Note:

These are the settings used in the video: 



What the different settings mean:
• Detection Distance: how far the attraction Force Works
• Max Velocity & Force Scale: how strong the Forces are applied
• Group Forces Only: let’s you choose if the forces work only within one group or also on the other groups
• Container Settings, Width/Hight: to define the size of the simulation area
• Wrap Particles: Periodic or non-periodic edges
• Render Mode: Different visualisation options
• Starging Parameters, particle Count, Number of Rows, Spacing: to set starting possition
• Random Start Phase - Size: To either give them all the same harmonious vibration or Random
• Particle Group: To set the % of the total amount of particles, their vibration size between a-b, color.
• Save Settings, Apply, Simulate: To save the changes and apply them, and run or stop the simulation.
• You can also adjust the number of particles at the top of the file "Parameters.gd"
var MAX_BOIDS = 20000