File Exchange

image thumbnail

3D Koch snowflake

version 4.6 (48.9 KB) by Nicolas Douillet
Function to compute, display, and save the triangular base 3D Koch snowflake at any iteration / depth level

7 Downloads

Updated 10 Sep 2020

View Version History

View License

Please first check the examples tab (doc) here on the right for a complete description.

Once downloaded, typewrite 'doc Koch_snowflake_3D' or 'help Koch_snowflake_3D' in Matlab console for support.

Cite As

Nicolas Douillet (2020). 3D Koch snowflake (https://www.mathworks.com/matlabcentral/fileexchange/73247-3d-koch-snowflake), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Nicolas Douillet

nb_it = 0 gives the stellated octahedron.

Nicolas Douillet

Color rendering used for this cover image is radius based, i.e. by computing each vertex distance to the origin : C = sqrt(sum(V.^2,2)); trisurf(T,V(:,1),V(:,2),V(:,3),C); colormap('winter');

Nicolas Douillet

Write and save the vertex V and the face sets T (in a .ply or .stl file for instance) before sending it to your favorite 3D printing manufacturer. Such file format writer is not included here, but may easily be found on this file exchange. Successfully tested for 3D printing. View and purchase here : https://www.sculpteo.com/fr/print/4_lvl_koch_snowflake_3d_original/VQ6wh8D3?uuid=HocXdM6UIytdCK364s3V1f

Nicolas Douillet

Display function based on fill3 is still very greedy in cpu time as well as the number of faces very quickly grows. From nb_iterations >= 3 it becomes very slow to get a display. My advice is to save V and T, to write a file and then to use another 'way' to display it (with a more efficient 3D display engine).

Nicolas Douillet

New version is coming for 3D printing. Waiting for it, to prevent from creating non manifold edges, just comment lines relative to remove duplicated vertices and triangles (l121-123).

Nicolas Douillet

Tip : from nb_iterations = 4, and if using write_ply.m you struggle with displaying the set out of Matlab [...] try to replace in the file header "uchar ushort" by "uint8 uint32" this should help ;-)

Nicolas Douillet

Koch_snowflake_3D is a function to compute a triangular based 3D Koch snowflake (fractal object) with some options (nb_iterations, display_option). Giving the resulting sets of vertices and triangles, it is almost 3D printing ready. You just need to write them in a .ply file for instance.

It is available for printing in my Sculpteo online shop :

- At iteration #3 : https://www.sculpteo.com/fr/print/3_lvl_koch_snowflake_3d_original/r7oEqSec?uuid=433MHc5nm1JX230AxoiZDd
- At iteration #4 : https://www.sculpteo.com/fr/print/4_lvl_koch_snowflake_3d_original/VQ6wh8D3?uuid=5bvvpOKbQZ8OAt8I2iJDJg
- At iteration #5 : https://www.sculpteo.com/fr/print/flocon-de-koch-tetraedrique-niveau-5/unwHePDn?uuid=VAb2Mb66wPUvfPlifoBeA

You may also have a look at some additional images in my Flikr gallery :
https://www.flickr.com/photos/153363591@N05/albums/72157689739929586

A cubic based version is also available here :

https://fr.mathworks.com/matlabcentral/fileexchange/73216-cubic-based-3d-koch-snowflake?s_tid=prof_contriblnk

/_!_\ Since the number of triangles increases very rapidly from an iteration of the fractal to the following, and unless your computer has very powerful computation abilities, memory, and a very strong graphic card, you should not set nb_iterations parameter value greater than ~ 5 if you want to display the result (main part of the CPU time of this algorithm : nb triangles loops on fill3 function)... or else, use your favourite mesh laboratory to display it ;-) /_!_\

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!