You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RUN echo 'deb http://download.opensuse.org/repositories/devel:/languages:/crystal/xUbuntu_20.04/ /' | sudo tee /etc/apt/sources.list.d/devel:languages:crystal.list
Copy file name to clipboardExpand all lines: SConstruct
+54-4
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,66 @@ This provides Builder objects for each of the language implementations in the AA
5
5
6
6
Currently, the aim is to provide a way to compile or copy the implementation files to the build directory, as well as to provide ways to run them and capture their output.
7
7
8
-
To run the compilation for all implmeentations in one language, e.g. Rust, run the command `scons build/c`, and the resulting executables will be available in the `cuild/c` directory, each in their respective algorithm directory, containing the executable."""
8
+
To run the compilation for all implementations in one language, e.g. C, run the command `scons build/c`, and the resulting executables will be available in the `build/c` directory, each in their respective algorithm directory, containing the executable."""
At first glance, this set of functions looks like an incomprehensible mess of magic numbers to create a specific result, and in a sense, that is precisely correct.
30
30
That said, we will go through each function and explain how it works, while also providing a simple chaos game implementation in code.
@@ -54,7 +54,7 @@ Now let's hop into disecting the Barnsley fern by seeing how each transform affe
54
54
| -------- | --------- |
55
55
|$$f_1(P) = \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ <p> This operation moves every point to a single line. | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_rnd_0.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
56
56
|$$f_2(P) = \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation moves every point up and to the right. | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_rnd_1.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
57
-
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation rotates every point to the left. | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_rnd_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
57
+
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation rotates every point to the left. | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_rnd_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
58
58
|$$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix}$$ <p> This operation flips every point and rotates to the right.| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_rnd_3.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
59
59
60
60
At this stage, it *might* be clear what is going on, but it's not exactly obvious.
@@ -71,7 +71,7 @@ The easiest way to make sense of this is to show the operations on the Barnsley
71
71
| -------- | --------- |
72
72
|$$f_1(P) = \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_fern_0.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
73
73
|$$f_2(P) = \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_fern_1.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
74
-
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_fern_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
74
+
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_fern_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
75
75
|$$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix}$$| <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/affine_fern_3.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
76
76
77
77
Here, the self-similar nature of the fern becomes apparent.
@@ -86,7 +86,7 @@ To account for this, each function is also given a probability of being chosen:
@@ -98,7 +98,7 @@ Here are a few examples of ferns that can be generated by modifying constituent
98
98
| -------- | --------- |
99
99
|$$f_1(P) = \begin{bmatrix} \tau &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5 $$ <p> Turning stems to leaves | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/fern_twiddle_0.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
100
100
|$$f_2(P) = \begin{bmatrix} 0.85 & \tau \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> where $$ -0.01 < \tau < 0.09 $$ <p> Changing fern tilt | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/fern_twiddle_1.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
101
-
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} \tau \\ 1.6 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking left leaves | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/fern_twiddle_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
101
+
|$$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} \tau \\ 1.6 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking left leaves | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/fern_twiddle_2.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
102
102
|$$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} \tau \\ 0.44 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking right leaves | <divstyle="text-align:center"> <videostyle="width:100%"controlsloop> <sourcesrc="res/fern_twiddle_3.mp4"type="video/mp4"> Your browser does not support the video tag. </video> </div> |
103
103
104
104
As an important note: the idea of modifying a resulting image by twiddling the knobs of an affine transform is the heart of many interesting methods, including fractal image compression where a low resolution version of an image is stored along with a reconstructing function set to generate high-quality images on-the-fly {{ "fractal-compression" | cite }}{{ "saupe1994review" | cite }}.
@@ -135,6 +135,8 @@ The biggest differences between the two code implementations is that the Barnsle
0 commit comments