Sierpinski carpet with rounded corners

Hi,
I am trying to create a Sierpinski carpet for two different shapes (triangular, rectangular) with a rounded shape. I am just unable to catch how the radius variable is taken in the example script rounded circle script.
I try to combine Sierpinski triangle script with rounded edge but something is wrong to copy and paste the structure at the right location. Here is my try.
test.fsp (228.3 KB)

I can certainly help you with this. To make sure we are on the same page, can you provide me with the drawings of the exact structures you want to create?

Hey @skim,
I want to create Sierpinski carpet for square shape and triangular shape like this but with a rounded edge object.


If the technique works, I can set n_sides = 3 for triangles carpet and 4 for square carpet.

@visvas, I am almost there with the script, but one unknown thing is whether the ‘radius’ of each rectangle corner is to be kept constant or scale with the size of the individual rectangles.Note that if you keep the radius constant, then there comes a case where the radius of the rectangle becomes larger than half the side of the rectangle, which is unphysical.

Hey @skim, the whole idea is to take fabrication error into account, so we need to scale the corner radius to make it realistic. Otherwise if I keep on increasing the fractal order, the corner radius will be much larger then the physical size of the object itself, and it will make no sense, as you mensioned.
I would like to see the script.

@visvas, Here’s the script for Sierpinski carpet with rounded corners.
kx-52514-1.lsf (1.1 KB)

This is the results for different values of N:

The above script together with the previous script for Sierpinski triangles should provide enough information for you to create the Sierpinski triangle with rounded corners. Let me know if you need further assistance with this.

@skim, This looks good but I think this requires some explanation for the understanding of the code. First of all, it doesn’t work if I set the order as 0, 1. You are calculating the V matrix, which is object dependent (square in this case). So, this means if I want to convert this into Sierpinski hexagon, I should calculate V matrix for every 60 degrees, right?
And how did you calculate this x and y, I didn’t get this matrix.

x1 = a/3^(n-1)([1;4;7;7;7;4;1;1]+0.5);
y1 = a/3^(n-1)
([1;1;1;4;7;7;7;4]+0.5);
x2 = a/3^(n-1)(4+0.5);
y2 = a/3^(n-1)
(4+0.5);
Can you please tell how to calculate this x and y for Sierpinski hexagon .
Lastly, can I placed the carpet at center?

\(\color{red}{Q1}\). it doesn’t work if I set the order as 0, 1.
\(\color{blue}{A1}\). N = 0 and 1 correspond to single squares with differing sizes. So, it should be straightforward to create them. They do not follow the patterning rules for N = 2 and over, hence were left out from the code I used.

\(\color{red}{Q2}\). You are calculating the V matrix, which is object dependent (square in this case). So, this means if I want to convert this into Sierpinski hexagon , I should calculate V matrix for every 60 degrees, right?
\(\color{blue}{A2}\). That is correct.

\(\color{red}{Q3}\). How did you calculate this x and y, I didn’t get this matrix.
\(\color{blue}{A3}\). The matrix corresponds to the center of the eight small rounded squares (x1 and y1) and the center of the bigger rounded square (x2 and y2) for the smallest unit cell marked by a white square. For N=3 and over, this unit cell is copied eight times again and a central square is formed. This process continues until the whole area is filled.

\(\color{red}{Q4}\). Lastly, can I placed the carpet at center?
\(\color{blue}{A4}\). The code uses the bottom left corner of the pattern as the origin. You can select all the structures and move them by \((-\frac{3a}{2},-\frac{3a}{2})\) to set the origin to the center of the structure.