-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2d-fractals-mandelbrot-julia.html
More file actions
341 lines (288 loc) 路 12.3 KB
/
Copy path2d-fractals-mandelbrot-julia.html
File metadata and controls
341 lines (288 loc) 路 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!-- FCT NOVA | FCT-UNL (Faculty of Sciences and Technology of New University of Lisbon) -->
<!-- Integrated Master (BSc./MSc.) of Computer Engineering -->
<!-- Computer Graphics and Interfaces (2016-2017) -->
<!-- Lab Work 1 - Fractals - Benoit Mandelbrot & Gaston Julia Sets -->
<!-- Daniel Filipe Pimenta - no. 45404 - d.pimenta@campus.fct.unl.pt -->
<!-- Ruben Andr茅 Barreiro - no. 42648 - r.barreiro@campus.fct.unl.pt -->
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="https://raw.githubusercontent.com/rubenandrebarreiro/rubenandrebarreiro.github.io/master/assets/images/javascript-logo-1.png"/>
<script id="vertex-shader" type="x-shader/x-vertex">
uniform float scale;
uniform vec2 center;
attribute vec4 vPosition;
varying vec2 fPosition;
void main() {
gl_Position = vPosition;
fPosition = vec2(center.x+vPosition.x/scale, center.y+vPosition.y/scale);
}
</script>
<script id="fragment-shader" type="x-shader/x-fragment">
precision mediump float;
uniform float factor;
uniform vec2 c;
uniform bool mandelbrot;
const int maxiterations = 100;
varying vec2 fPosition;
int fractal(vec2 z0, vec2 c) {
vec2 z = z0;
for (int i = 0; i < maxiterations; i++) {
z = vec2(z.x * z.x - z.y * z.y, z.x * z.y + z.x * z.y) + c;
if (z.x * z.x + z.y * z.y > 4.0)
return i;
}
return -1;
}
vec3 paletize(float v, float factor) {
if (v < 0.0)
return vec3(0);
float vv = v * factor;
return vec3(sin(vv/3.0), cos(vv/6.0), cos(vv/(12.0+3.14/4.0)));
}
void main() {
vec2 z0 = mandelbrot ? c : fPosition;
vec2 c0 = mandelbrot ? fPosition : c;
int color_index = fractal(z0, c0);
vec3 color = paletize(float(color_index), factor);
gl_FragColor = vec4(color, 1.0);
}
</script>
<script type="text/javascript" src="2d-fractals-mandelbrot-julia.js"></script>
<script type="text/javascript" src="common/webgl-utils.js"></script>
<script type="text/javascript" src="common/initShaders.js"></script>
<script type="text/javascript" src="common/MV.js"></script>
<style>
body {
color: #000;
font-family:Tahoma;
font-size:13px;
font-weight: bold;
background-color: #000000;
background-image: url("imgs/JPGs/background.jpg");
}
#container {
position: absolute;
border-radius: 5px;
}
#workDescription {
background:#eeeeee;
position: absolute;
left: 8px; top: 550px;
padding:0;
margin:0;
overflow:hidden;
width: 512px;
border-radius: 5px;
text-align: center;
}
#authorsInfo {
background:#eeeeee;
position: absolute;
left: 8px; top: 794px;
padding:0;
margin:0;
overflow:hidden;
width: 512px;
border-radius: 5px;
text-align: center;
}
#instructions {
background:#eeeeee;
position: absolute;
left: 540px; top: 24px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
#settings {
background:#eeeeee;
position: absolute;
left: 540px; top: 176px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: center;
}
#juliaSetInfo {
background:#eeeeee;
position: absolute;
left: 540px; top: 404px;
padding:0;
margin:0;
overflow:hidden;
width: 600px;
border-radius: 5px;
text-align: justify;
}
#mandelbrotSetInfo {
background:#eeeeee;
position: absolute;
left: 1160px; top: 24px;
padding:0;
margin:0;
overflow:hidden;
width: 740px;
border-radius: 5px;
text-align: justify;
}
a {
color: #35b0ab;
}
</style>
</head>
<body>
<title>Fractals - Benoit Mandelbrot & Gaston Julia Sets</title>
<br>
<div id="container" style="display: inline-block; vertical-align: top">
<canvas id="gl-canvas" width="512" height="512" style="border-radius: 5px;">
Oops... your browser doesn't support the HTML5 canvas element"
</canvas>
</div>
<br/>
<br/>
<div id="workDescription">
<h2>
<a href="https://www.fct.unl.pt/en/education/course/integrated-master-computer-science">
Computer Science and Engineering
<br/>
Integrated Master
</a>
</h2>
<h3>
@ <a href="https://www.fct.unl.pt/en"><i>FCT NOVA | FCT/UNL
<br/>
(Faculty of Sciences and Technology of New University of Lisbon)</i></a>
</h3>
<br/>
<h3>
<a href="http://www.unl.pt/guia/2018/fct/UNLGI_getUC?uc=8150">
Computer Graphics and Interfaces
</a>
<br/>
(2017/2018)
</h3>
<h4>
Lab Work 1 (<a href="https://en.wikipedia.org/wiki/Fractal">Fractals</a> - <a href="https://en.wikipedia.org/wiki/Benoit_Mandelbrot">Benoit Mandelbrot</a> & <a href="https://en.wikipedia.org/wiki/Gaston_Julia">Gaston Julia</a> Sets)
</h4>
</div>
<div id="authorsInfo">
<h2>
Authors/Contributors
</h2>
<h3>
<u><i>Rúben André Barreiro</i></u>
</h3>
<h4>
no. 42648 (<a href="mailto:r.barreiro@campus.fct.unl.pt">r.barreiro@campus.fct.unl.pt</a>)
</h4>
<h3>
<u><i>Daniel Filipe Pimenta</i></u>
</h3>
<h4>
no. 45404 (<a href="mailto:d.pimenta@campus.fct.unl.pt">d.pimenta@campus.fct.unl.pt</a>)
</h4>
</div>
<div id="instructions">
<h2>
Instructions
</h2>
<font size="2">
- Use <b><i>'Q'</i></b> and <b><i>'A'</i></b> keys dive/emerge;
<br/>
- Use <b><i>click/drag/release</i></b> in the canvas to move center point;
<br/>
- Choose the current <b><i>Fractal's Set</i></b> in use (<i>Benoit Mandelbrot</i> or <i>Gaston Julia</i>);
<br/>
- Choose also the current <i>Factor</i> to the <i>Scale</i> of the current <b><i>Fractal</i></b> in use;
<br/>
<br/>
</font>
</div>
<div id="settings">
<h2>
Settings/Adjustments
</h2>
<b>Factor</b>
<br/>
<br/>
<input id="factor" type="range" min="0.00" max="2.00" step="0.01" value="1.0">
<br/>
<br/>
<br/>
<b>Fractal type</b>
<br/>
<br/>
<select id="fractal">
<option>Mandelbrot</option>
<option>Julia c=-0.4+0.6i</option>
<option>Julia c=0.285+0i</option>
<option>Julia c=0.285+0.01i</option>
<option>Julia c=-0.8+0.156i</option>
<option>Julia c=-0.8i</option>
<!-- extra -->
<option>Julia c=0.45+0.1428i</option>
<option>Julia c=-0.70176-0.3842i</option>
<option>Julia c=-0.835-0.2321i</option>
</select>
<br/>
<br/>
</div>
<div id="juliaSetInfo">
<h2 style="padding-left: 20px;">
Julia Set
</h2>
<img src="imgs/JPGs/julia-set.jpg" alt="Julia Set" style="padding-left: 20px;padding-right: 20px;" height="200" width="200">
<p style="padding-left: 20px;padding-right: 20px;">
In the context of complex dynamics, a topic of mathematics, the <i>Julia</i> set and the <i>Fatou</i> set are two complementary sets (<i>Julia</i> "laces" and <i>Fatou</i> "dusts") defined from a function. Informally, the <i>Fatou</i> set of the function consists of values with the property that all nearby values behave similarly under repeated iteration of the function, and the <i>Julia</i> set consists of values such that an arbitrarily small perturbation can cause drastic changes in the sequence of iterated function values. Thus the behavior of the function on the <i>Fatou</i> set is "regular", while on the <i>Julia</i> set its behavior is "chaotic".
</p>
<p style="padding-left: 20px;padding-right: 20px;">
The <i>Julia</i> set of a function <i>f</i> is commonly denoted <i>J(f)</i>, and the <i>Fatou</i> set is denoted <i>F(f)</i>. These sets are named after the French mathematicians <i>Gaston Julia</i> and <i>Pierre Fatou</i> whose work began the study of complex dynamics during the early 20th century.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
<font size="2"><i>Source: <a href="https://en.wikipedia.org/wiki/Julia_set">Wikipedia</a></i></font>
</p>
</div>
<div id="mandelbrotSetInfo">
<h2 style="padding-left: 20px;">
Mandelbrot Set
</h2>
<img src="imgs/JPGs/mandelbrot-set.jpg" alt="Mandelbrot Set" style="padding-left: 20px;padding-right: 20px;" height="300" width="400">
<p style="padding-left: 20px;padding-right: 20px;">
The <i>Mandelbrot</i> set is the set of complex numbers <i>c</i> for which the function
<br/>
<i>f<sub>c</sub>(z) = z<sup>2</sup> + c</i>
<br/>
doesn't diverge when iterated from <i>z = 0</i>, i.e., for which the sequence
<br/>
<i>f<sub>c</sub>(0)</i>, <i>f<sub>c</sub>(f<sub>c</sub>(0))</i>, etc., remains bounded in absolute value.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
Its definition and name are due to <i>Adrien Douady</i>, in tribute to the mathematician <i>Benoit Mandelbrot</i>. The set is connected to a <i>Julia</i> set, and related <i>Julia</i> sets produce similarly complex fractal shapes.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
<i>Mandelbrot</i> set images may be created by sampling the complex numbers and testing, for each sample point <i>c</i>, whether the sequence
<br/>
<i>f<sub>c</sub>(0), f<sub>c</sub>(f<sub>c</sub>(0))</i>, ... goes to infinity (in practice, whether it leaves some predetermined bounded neighborhood of 0 after a predetermined number of iterations).
<br/>
Treating the real and imaginary parts of <i>c</i> as image coordinates on the complex plane, pixels may then be coloured according to how soon the sequence
<br/>
<i>|f<sub>c</sub>(0)|</i>, <i>|f<sub>c</sub>(f<sub>c</sub>(0))|</i>, ... crosses an arbitrarily chosen threshold, with a special color (usually black) used for the values of <i>c</i> for which the sequence hasn't crossed the threshold after the predetermined number of iterations (this is necessary to clearly distinguish the <i>Mandelbrot</i> set image from the image of its complement). If <i>c</i> is held constant and the initial value of <i>z</i> (denoted by <i>z<sub>0</sub></i>) is variable instead, one obtains the corresponding <i>Julia</i> set for each point <i>c</i> in the parameter space of the simple function.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
Images of the <i>Mandelbrot</i> set exhibit an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive detail at increasing magnifications. The "style" of this repeating detail depends on the region of the set being examined. The set's boundary also incorporates smaller versions of the main shape, so the fractal property of self-similarity applies to the entire set, and not just to its parts.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
The <i>Mandelbrot</i> set has become popular outside mathematics both for its aesthetic appeal and as an example of a complex structure arising from the application of simple rules. It's one of the best-known examples of mathematical visualization and mathematical beauty.
</p>
<p style="padding-left: 20px;padding-right: 20px;">
<font size="2"><i>Source: <a href="https://en.wikipedia.org/wiki/Mandelbrot_set">Wikipedia</a></i></font>
</p>
</div>
</body>
</html>