Skip to content
Advertisement

Non overlapping random shapes on 2D plane

Objective: I want to create random non-overlapping irregular rounded shapes (contours) on a 2D plane, similar to a sandstone microstructure as shown below, to perform an oil flooding experiment using computer vision.

Sandstone Microstructure

Approach: I have previously done a similar thing but with circular shapes instead of random shapes. The result is as below.

Circular Shapes

Also, I am aware of the programming way of creating closed Bezier curves.

Help: But I am not able to combine both these steps into a single script. Also if there are any other alternatives it is more than welcome.

Code:

  1. Circular Shapes inside 2D plane

  2. Bezier Curves

Advertisement

Answer

I took most of the code from ImportanceOfBeingErnest’s answer here: Create random shape/contour using matplotlib. Some fine-tuning is needed to tighten the space between the random shapes but the basic idea is there

JavaScript

A random generated result: enter image description here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement