Function to compute and display a Sierpinski sphere.

Author & support : nicolas.douillet (at) free.fr, 2017-2019.




Spherpinski(nb_iterations, option_fill);

Spherpinski(nb_iterations, option_fill, option_display);

[V,T] = Spherpinski(nb_iterations, option_fill, option_display);


Spherpinski(nb_iterations) computes and display the nb_iterations Sierpinski sphere based on the regular octahedron, and included in the unitary sphere.

Spherpinski(nb_iterations, option_fill) fills the octahedron remaining empty quadrants with small Sierpinski spherical pieces when option_fill is set to 'double', and doesn't -default behaviour- when it is set to 'simple'.

Spherpinski(nb_iterations, option_fill, option_display) displays it when option_display is logical true (default), and doesn't when it is logical false.

[V,T] = Spherpinski(nb_iterations, option_fill, option_display) stores the resulting vertices coordinates in the array V, and the corresponding triplet indices list in the array T.

See also

Sierpinski_ball | Sierpinski_tetrahedron | Koch_snowflake_3D | cubic_based_3D_Koch_snowflake | fractalCarpet

Input arguments

- nb_iterations : positive -or null- numeric integer.

- option fill : character string in the set {*'simple,'double','SIMPLE','DOUBLE'}.

- option_display : either logical, *true/false or numeric *1/0.

Output arguments

     |  |  |
- V [Vx Vy Vz] : numeric array of doubles. Vertices coordinates. Size = [nb_vertices, 3].
     |  |  |
     |  |  |
- T [T1 T2 T3] : numeric array of positive integers. List of triplet indices for triangles. Size = [nb_triangles, 3].
     |  |  |

Example #1

Compute and display the simple Sierpinski sphere at iteration 4


Example #2

Compute and display the double Sierpinski sphere at iteration 7. Store vertices and triangles.

[V,T] = Spherpinski(7, 'double', true);