9
9
10
10
/**
11
11
* Calculate and render Mandelbrot set as image to file.
12
- * Implementation is inspired by Pavol Hejny, https://www.pavolhejny.com/.
12
+ * Implementation was inspired from Pavol Hejny, https://www.pavolhejny.com/.
13
13
*/
14
14
final class MandelbrotSet
15
15
{
@@ -64,15 +64,15 @@ public function generate(MandelbrotSetRequest $request): void
64
64
$ alpha_color = imagecolorallocatealpha ($ im , 0 , 0 , 0 , 127 );
65
65
imagefill ($ im , 0 , 0 , $ alpha_color );
66
66
67
- for ($ y = 0 ; $ y <= $ dim_y ; $ y ++) { // Procházení a vyhodnocení každého bodu
68
- for ($ x = 0 ; $ x <= $ dim_x ; $ x ++) { // Zjištění souřadnic bodu, který se přičte v každé iteraci
67
+ for ($ y = 0 ; $ y <= $ dim_y ; $ y ++) { // browsing and evaluating each point
68
+ for ($ x = 0 ; $ x <= $ dim_x ; $ x ++) { // find the coordinates of the point that is added in each iteration
69
69
$ c1 = $ min_x + ($ max_x - $ min_x ) / $ dim_x * $ x ;
70
70
$ c2 = $ min_y + ($ max_y - $ min_y ) / $ dim_y * $ y ;
71
- $ z1 = 0 ; // aktuální číslo
71
+ $ z1 = 0 ; // current number
72
72
$ z2 = 0 ;
73
73
74
- for ($ i = 0 ; $ i < $ itt ; $ i ++) { // Main iterator
75
- // Zjištění vzdálenosti od 0+ 0i
74
+ for ($ i = 0 ; $ i < $ itt ; $ i ++) { // main iterator
75
+ // finding the distance from 0 + 0i
76
76
$ distance = sqrt ($ z1 * $ z1 + $ z2 * $ z2 );
77
77
78
78
if ((int ) $ distance !== 0 ) {
@@ -81,26 +81,26 @@ public function generate(MandelbrotSetRequest $request): void
81
81
$ angle = 0 ;
82
82
}
83
83
84
- if ($ z2 < 0 ) { // Úhel
84
+ if ($ z2 < 0 ) { // angle
85
85
$ angle = (2 * M_PI ) - $ angle ;
86
86
}
87
87
88
- $ angle *= $ d1 ; // Vynásobení úhlu
89
- $ distance = $ distance ** $ d2 ; // Mocnění vzdálenosti
90
- // Výpočet nového x, y
88
+ $ angle *= $ d1 ; // multiply the angle
89
+ $ distance = $ distance ** $ d2 ; // power of distance
90
+ // calculation of the new x, y
91
91
$ z1 = cos ($ angle ) * $ distance ;
92
92
$ z2 = sin ($ angle ) * $ distance ;
93
- // Přičtení souřadnic bodu
93
+ // adding point coordinates
94
94
$ z1 += $ c1 ;
95
95
$ z2 += $ c2 ;
96
96
97
- // Pokud je bod ve vzdálenosti 2 nebo větší, bod v množině nebude a iterování lze ukončit
97
+ // if the point is at a distance of 2 or greater, the point will not be in the set and the iteration can be terminated
98
98
if ($ z1 * $ z1 + $ z2 * $ z2 >= 4 ) {
99
99
break ;
100
100
}
101
101
}
102
102
103
- // Pokud v každé iteraci držel nový bod ve vzdálenosti 2 nebo méně, je původní bod vyplněn .
103
+ // if in each iteration he held a new point at a distance of 2 or less, the original point is filled .
104
104
if ($ i >= $ itt ) {
105
105
imagesetpixel ($ im , (int ) round ($ x ), (int ) round ($ y ), $ blackColor );
106
106
}
0 commit comments