Fractals in Virtual Reality

• Sharebar

Logo programming with its recursive procedure capability enables easy creation of fractal geometry. In VRMath2, many of the existing fractals by tranditional 2D Logo programs can be viewed in 3D and reconstructed to be 3D fractals. This project will explore existing and new ideas about fractals, and use the 3D Logo programming environemnt in VRMath2 to generate and share 3D fractals online. Below are some classic examples of fractals.

Fractals in the nature

1. Fern leaf

Perhaps one of the most popular fractals in the nature, the fern leaf has a recursive structure, which can be described and coded using the Logo turtle geometry.

 `; Recursive fern procedure;TO fern :size :sign IF :size < 1 [ STOP ] FD :size RT 70 * :sign fern :size * 0.5 :sign * -1 LT 70 * :sign FD :size LT 70 * :sign fern :size * 0.5 :sign RT 70 * :sign RT 7 * :sign fern :size - 1 :sign LT 7 * :sign JB :size * 2 ; jb = jumpbackENDCS ; clearscreenSETBG 29 ; set background to index 29CM ; centimeterNCOFF ; next color offSETPCNAME "green ; set pen color by nameRU 90 ; roll up 90 degreesPD ; pen downfern 16 1PU ; pen up`

In VRMath2, the third dimention can be utilised to cretae a curved 3D fern leaf, which is based on the 2D recursive procedure above.

 `; Recursive 3D fern procedureTO fern :size :sign :curve IF :size < 1 [ STOP ] ; exit condition FD :size RT 70 * :sign ; right branch fern :size * 0.5 :sign * -1 :curve ; alternates branches LT 70 * :sign FD :size LT 70 * :sign ; left branch fern :size * 0.5 :sign :curve RT 70 * :sign ; main body with a 7 degrees turn RT 7 * :sign RD :curve ; this rd (rollup) makes it 3D fern :size - 1 :sign :curve RU :curve LT 7 * :sign JB :size * 2 ; jb = jumpbackEND; beginning constructionCS ; clearscreenSETBG 29 ; set background 29: Blue-White ExamineCM ; centimeterSETPCNAME "green ; set pen color by nameRU 90 ; roll up 90 degreesPD ; pen downfern 16 1 10PU ; pen up`

2. Trees

There are a few popular trees created in traditional 2D Logo. In this project, we can experiemnt based on these 2D procedures and make 3D trees. Below are two tree examples, and you may copy the codes into the VRMath2 Editor to make them 3D.

 `; recursive tree;TO tree :sizeIF :size < 5 [FORWARD :size JUMPBACK :size STOP]FORWARD :size/3LEFT 30 tree :size*2/3 RIGHT 30FORWARD :size/6RIGHT 25 tree :size/2 LEFT 25FORWARD :size/3RIGHT 25 tree :size/2 LEFT 25FORWARD :size/6JUMPBACK :sizeENDRESET CLEARSCREENCM ; change to cemtimeterLINE ; change to line modeRU 90PD tree 100 PU`

Another tree (binary).

 `; Recursive tree;TO trunk :sizeIF :size < 5 [STOP]FD :sizeLT 30 trunk :size*.7RT 60 trunk :size*.7LT 30 JB :sizeEND RESETCSSETBG 29CMRU 90PDtrunk 100PU`

Mathematical fractals

Fractals are recursive and self-similar. Using mathematical ideas with recursive programming could produce a variety of fractals. Here are some well known fractals.

1. Koch snowflake