99
1010/**
1111 * 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/.
1313 */
1414final class MandelbrotSet
1515{
@@ -64,15 +64,15 @@ public function generate(MandelbrotSetRequest $request): void
6464 $ alpha_color = imagecolorallocatealpha ($ im , 0 , 0 , 0 , 127 );
6565 imagefill ($ im , 0 , 0 , $ alpha_color );
6666
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
6969 $ c1 = $ min_x + ($ max_x - $ min_x ) / $ dim_x * $ x ;
7070 $ c2 = $ min_y + ($ max_y - $ min_y ) / $ dim_y * $ y ;
71- $ z1 = 0 ; // aktuální číslo
71+ $ z1 = 0 ; // current number
7272 $ z2 = 0 ;
7373
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
7676 $ distance = sqrt ($ z1 * $ z1 + $ z2 * $ z2 );
7777
7878 if ((int ) $ distance !== 0 ) {
@@ -81,26 +81,26 @@ public function generate(MandelbrotSetRequest $request): void
8181 $ angle = 0 ;
8282 }
8383
84- if ($ z2 < 0 ) { // Úhel
84+ if ($ z2 < 0 ) { // angle
8585 $ angle = (2 * M_PI ) - $ angle ;
8686 }
8787
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
9191 $ z1 = cos ($ angle ) * $ distance ;
9292 $ z2 = sin ($ angle ) * $ distance ;
93- // Přičtení souřadnic bodu
93+ // adding point coordinates
9494 $ z1 += $ c1 ;
9595 $ z2 += $ c2 ;
9696
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
9898 if ($ z1 * $ z1 + $ z2 * $ z2 >= 4 ) {
9999 break ;
100100 }
101101 }
102102
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 .
104104 if ($ i >= $ itt ) {
105105 imagesetpixel ($ im , (int ) round ($ x ), (int ) round ($ y ), $ blackColor );
106106 }
0 commit comments