@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * for all j in [O..max[y][ : for all i in bords[$j] : |
57 | 57 | * (i,j) is a point inside an edge of the polygone |
58 | 58 | */ |
59 | - $bord_lenght = $max['x']; |
|
59 | + $bord_lenght = $max['x']; |
|
60 | 60 | if ($max['y'] > $bord_lenght) { |
61 | - $bord_lenght = $max['y']; |
|
61 | + $bord_lenght = $max['y']; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | //$bords = array_fill(0, $bord_lenght-1, array()); // building this array |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | /* adding the first point of the polygone */ |
68 | 68 | if (is_array($bords[$poly[0]['y']])) //avoid warning |
69 | - array_push($bords[$poly[0]['y']], $poly[0]['x']); |
|
69 | + array_push($bords[$poly[0]['y']], $poly[0]['x']); |
|
70 | 70 | |
71 | 71 | $i = 1; // we re-use $i and $old_pente bellow the loop |
72 | 72 | $old_pente=0; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | if ($poly[$i-1]['x'] == $poly[$i]['x']) |
79 | 79 | continue; // twice the same point |
80 | 80 | else { // infinite elevation of the edge |
81 | - if (is_array($bords[$poly[$i]['y']])) |
|
82 | - array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
81 | + if (is_array($bords[$poly[$i]['y']])) |
|
82 | + array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
83 | 83 | $old_pente=0; |
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - //echo 'point:'.$poly[$i]['y']; bug here |
|
88 | + //echo 'point:'.$poly[$i]['y']; bug here |
|
89 | 89 | // adding the point as a part of an edge |
90 | 90 | if (is_array($bords[$poly[$i]['y']])) //avoid warning |
91 | 91 | array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | if ($i>1) |
103 | 103 | if (($old_pente<0 && $pente>0) |
104 | 104 | || ($old_pente>0 && $pente<0)) { |
105 | - if (is_array($bords[$poly[$i]['y']])) //avoid warning |
|
106 | - array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
105 | + if (is_array($bords[$poly[$i]['y']])) //avoid warning |
|
106 | + array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
107 | 107 | |
108 | 108 | if (DEBUG) |
109 | 109 | echo '*('.$poly[$i]['x']. |
110 | 110 | ';'.$poly[$i]['y'].') '; |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | /* detect the direction of the elevation in Y */ |
114 | 114 | $dy_inc = ($poly[$i]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | // elevation between $poly[0]['x'] and $poly[1]['x']) |
138 | 138 | $rest = $poly[0]['y']-$poly[1]['y']; |
139 | 139 | if ($rest!=0) |
140 | - $pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest); |
|
140 | + $pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest); |
|
141 | 141 | else |
142 | - $pente1 = 0; |
|
142 | + $pente1 = 0; |
|
143 | 143 | |
144 | 144 | // elevation between $poly[$i-1]['x'] and $poly[0]['x']) |
145 | 145 | $pente = ($poly[$i-1]['x']-$poly[0]['x'])/ |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | |
152 | 152 | // doubling the first point if needed (see above) |
153 | 153 | if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) { |
154 | - if (is_array($bords[$poly[$i - 1]['y']])) |
|
155 | - array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
154 | + if (is_array($bords[$poly[$i - 1]['y']])) |
|
155 | + array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
156 | 156 | //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
157 | 157 | } |
158 | 158 | // doubling the last point if neededd |
159 | 159 | if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) { |
160 | - if (is_array($bords[$poly[$i-1]['y']])) //avoid warning |
|
161 | - array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x'])); |
|
160 | + if (is_array($bords[$poly[$i-1]['y']])) //avoid warning |
|
161 | + array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x'])); |
|
162 | 162 | //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
163 | 163 | } |
164 | 164 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | for ($i = 0; $i<$n; $i++) { // Y |
186 | 186 | //error_log(__FILE__.' - Border Num '.$i,0); |
187 | 187 | if (is_array($bords[$i])) { |
188 | - sort($bords[$i]); |
|
188 | + sort($bords[$i]); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | for ($j = 0; $j<sizeof($bords[$i]);$j+=2) { // bords |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) { |
197 | 197 | $res[$k][$i] = true; //filling the array with trues |
198 | 198 | if ($test == 1) { |
199 | - /*how to draw the polygon in a human way: |
|
199 | + /*how to draw the polygon in a human way: |
|
200 | 200 | In ubuntu : sudo apt-get install gnuplot |
201 | 201 | Create an empty file with all points with the result of this echos (No commas, no point, no headers) |
202 | 202 | In gnuplot: |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | For 2 polygons: plot "/home/jmontoya/test", "/home/jmontoya/test2" |
205 | 205 | A new window will appear with the plot |
206 | 206 | */ |
207 | - echo $k.' '.$i; echo '<br />'; |
|
207 | + echo $k.' '.$i; echo '<br />'; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | list($x,$y) = explode(';',$pcoord); |
309 | 309 | $points[] = array('x'=>$x,'y'=>$y); |
310 | 310 | } |
311 | - return $points; |
|
311 | + return $points; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | $mx = 0; |
322 | 322 | $my = 0; |
323 | 323 | foreach ($coords1 as $coord) { |
324 | - if ($coord['x'] > $mx) { |
|
324 | + if ($coord['x'] > $mx) { |
|
325 | 325 | $mx = $coord['x']; |
326 | - } |
|
326 | + } |
|
327 | 327 | if ($coord['y'] > $my) { |
328 | - $my = $coord['y']; |
|
328 | + $my = $coord['y']; |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | foreach ($coords2 as $coord) { |