Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Request #14925 - PHPCS

git-svn-id: https://svn.php.net/repository/pear/packages/Image_3D/trunk@270293 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 841c60a0f40dfc0e0c1ff58b99da113f49001eff 1 parent 8e0f28b
Daniel O'Connor authored December 02, 2008
16  Image/3D/Paintable/Light/Ambient.php
@@ -36,14 +36,14 @@
36 36
 /**
37 37
  * Image_3D_Light
38 38
  *
39  
- * @category   Image
40  
- * @package    Image_3D
41  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
42  
- * @copyright  1997-2005 Kore Nordmann
43  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
44  
- * @version    Release: @package_version@
45  
- * @link       http://pear.php.net/package/PackageName
46  
- * @since      Class available since Release 0.1.0
  39
+ * @category  Image
  40
+ * @package   Image_3D
  41
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  42
+ * @copyright 1997-2005 Kore Nordmann
  43
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  44
+ * @version   Release: @package_version@
  45
+ * @link      http://pear.php.net/package/PackageName
  46
+ * @since     Class available since Release 0.1.0
47 47
  */
48 48
 class Image_3D_Light_Ambient extends Image_3D_Light {
49 49
     
16  Image/3D/Paintable/Light/Point.php
@@ -36,14 +36,14 @@
36 36
 /**
37 37
  * Image_3D_Light_Point
38 38
  *
39  
- * @category   Image
40  
- * @package    Image_3D
41  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
42  
- * @copyright  1997-2005 Kore Nordmann
43  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
44  
- * @version    Release: @package_version@
45  
- * @link       http://pear.php.net/package/PackageName
46  
- * @since      Class available since Release 0.1.0
  39
+ * @category  Image
  40
+ * @package   Image_3D
  41
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  42
+ * @copyright 1997-2005 Kore Nordmann
  43
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  44
+ * @version   Release: @package_version@
  45
+ * @link      http://pear.php.net/package/PackageName
  46
+ * @since     Class available since Release 0.1.0
47 47
  */
48 48
 class Image_3D_Light_Point extends Image_3D_Light {
49 49
     
16  Image/3D/Paintable/Light/Spotlight.php
@@ -36,14 +36,14 @@
36 36
 /**
37 37
  * Image_3D_Light
38 38
  *
39  
- * @category   Image
40  
- * @package    Image_3D
41  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
42  
- * @copyright  1997-2005 Kore Nordmann
43  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
44  
- * @version    Release: @package_version@
45  
- * @link       http://pear.php.net/package/PackageName
46  
- * @since      Class available since Release 0.1.0
  39
+ * @category  Image
  40
+ * @package   Image_3D
  41
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  42
+ * @copyright 1997-2005 Kore Nordmann
  43
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  44
+ * @version   Release: @package_version@
  45
+ * @link      http://pear.php.net/package/PackageName
  46
+ * @since     Class available since Release 0.1.0
47 47
  */
48 48
 class Image_3D_Light_Spotlight extends Image_3D_Light {
49 49
     
101  Image/3D/Paintable/Object.php
@@ -36,16 +36,17 @@
36 36
 /**
37 37
  * Image_3D_Object
38 38
  *
39  
- * @category   Image
40  
- * @package    Image_3D
41  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
42  
- * @copyright  1997-2005 Kore Nordmann
43  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
44  
- * @version    Release: @package_version@
45  
- * @link       http://pear.php.net/package/PackageName
46  
- * @since      Class available since Release 0.1.0
  39
+ * @category  Image
  40
+ * @package   Image_3D
  41
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  42
+ * @copyright 1997-2005 Kore Nordmann
  43
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  44
+ * @version   Release: @package_version@
  45
+ * @link      http://pear.php.net/package/PackageName
  46
+ * @since     Class available since Release 0.1.0
47 47
  */
48  
-class Image_3D_Object implements Image_3D_Interface_Paintable {
  48
+class Image_3D_Object implements Image_3D_Interface_Paintable
  49
+{
49 50
     
50 51
     protected $_polygones;
51 52
     
@@ -54,25 +55,39 @@ public function __construct()
54 55
         $this->_polygones = array();
55 56
     }
56 57
     
57  
-    public function getPolygonCount() {
  58
+    public function getPolygonCount() 
  59
+    {
58 60
         return count($this->_polygones);
59 61
     }
60 62
     
61  
-    public function setColor(Image_3D_Color $color) {
62  
-        foreach ($this->_polygones as $polygon) $polygon->setColor($color);
  63
+    public function setColor(Image_3D_Color $color) 
  64
+    {
  65
+        foreach ($this->_polygones as $polygon) {
  66
+            $polygon->setColor($color);
  67
+        }
63 68
     }
64 69
     
65  
-    public function setOption($option, $value) {
66  
-        foreach ($this->_polygones as $polygon) $polygon->setOption($option, $value);
  70
+    public function setOption($option, $value) 
  71
+    {
  72
+        foreach ($this->_polygones as $polygon) { 
  73
+            $polygon->setOption($option, $value); 
  74
+        }
67 75
     }
68 76
 
69  
-    public function transform(Image_3D_Matrix $matrix, $id = null) {
  77
+    public function transform(Image_3D_Matrix $matrix, $id = null) 
  78
+    {
70 79
         
71  
-        if ($id === null) $id = substr(md5(microtime()), 0, 8);
72  
-        foreach ($this->_polygones as $polygon) $polygon->transform($matrix, $id);
  80
+        if ($id === null) { 
  81
+            $id = substr(md5(microtime()), 0, 8); 
  82
+        }
  83
+
  84
+        foreach ($this->_polygones as $polygon) { 
  85
+            $polygon->transform($matrix, $id); 
  86
+        }
73 87
     }
74 88
     
75  
-    public function getPolygones() {
  89
+    public function getPolygones() 
  90
+    {
76 91
         return $this->_polygones;
77 92
     }
78 93
     
@@ -86,16 +101,16 @@ protected function _buildInzidenzGraph()
86 101
         $polygons = $this->getPolygones();
87 102
 
88 103
         $surfaces = array();
89  
-        $edges = array();
90  
-        $points = array();
  104
+        $edges    = array();
  105
+        $points   = array();
91 106
 
92 107
         $point_hash = array();
93  
-        $edge_hash = array();
  108
+        $edge_hash  = array();
94 109
 
95 110
         foreach ($polygons as $nr => $polygon) {
96 111
             $p_points = $polygon->getPoints();
97 112
 
98  
-            $last_index = false;
  113
+            $last_index  = false;
99 114
             $first_index = false;
100 115
             foreach ($p_points as $point) {
101 116
                 // Add point to edge
@@ -103,8 +118,9 @@ protected function _buildInzidenzGraph()
103 118
                 if (isset($point_hash[$p_p_hash])) {
104 119
                     $p_p_index = $point_hash[$p_p_hash];
105 120
                 } else {
106  
-                    $points[] = $point;
  121
+                    $points[]  = $point;
107 122
                     $p_p_index = count($points) - 1;
  123
+
108 124
                     $point_hash[$p_p_hash] = $p_p_index;
109 125
                 }
110 126
 
@@ -117,7 +133,9 @@ protected function _buildInzidenzGraph()
117 133
                         $surfaces[$nr][] = $edge_hash[$p_e_hash];
118 134
                     } else {
119 135
                         $edges[] = $e_points;
  136
+
120 137
                         $edge_hash[$p_e_hash] = count($edges) - 1;
  138
+
121 139
                         $surfaces[$nr][] = $edge_hash[$p_e_hash];
122 140
                     }
123 141
                 } else {
@@ -135,9 +153,9 @@ protected function _buildInzidenzGraph()
135 153
             if (isset($edge_hash[$p_e_hash])) {
136 154
                 $surfaces[$nr][] = $edge_hash[$p_e_hash];
137 155
             } else {
138  
-                $edges[] = $e_points;
  156
+                $edges[]              = $e_points;
139 157
                 $edge_hash[$p_e_hash] = count($edges) - 1;
140  
-                $surfaces[$nr][] = $edge_hash[$p_e_hash];
  158
+                $surfaces[$nr][]      = $edge_hash[$p_e_hash];
141 159
             }
142 160
         }
143 161
 
@@ -148,19 +166,20 @@ protected function _buildInzidenzGraph()
148 166
         );
149 167
     }
150 168
 
151  
-    public function subdivideSurfaces($factor = 1) {
  169
+    public function subdivideSurfaces($factor = 1) 
  170
+    {
152 171
         for ($i = 0; $i < $factor; ++$i) {
153 172
             $data = $this->_buildInzidenzGraph();
154 173
 
155 174
             // Additional hash maps
156 175
             $edge_surfaces = array();
157  
-            $edge_middles = array();
158  
-            $point_edges = array();
  176
+            $edge_middles  = array();
  177
+            $point_edges   = array();
159 178
             
160 179
             // New calculated points
161 180
             $face_points = array();
162 181
             $edge_points = array();
163  
-            $old_points = array();
  182
+            $old_points  = array();
164 183
 
165 184
             // Calculate "face points"
166 185
             foreach ($data['surfaces'] as $surface => $edges) {
@@ -168,12 +187,13 @@ public function subdivideSurfaces($factor = 1) {
168 187
                 $points = array();
169 188
                 foreach ($edges as $edge) {
170 189
                     $points = array_merge($points, $data['edges'][$edge]);
  190
+
171 191
                     $edge_surfaces[$edge][] = $surface;
172 192
                 }
173 193
                 $points = array_unique($points);
174 194
 
175 195
                 // Calculate average
176  
-                $face_point = array(0, 0, 0);
  196
+                $face_point  = array(0, 0, 0);
177 197
                 $point_count = count($points);
178 198
                 foreach ($points as $point) {
179 199
                     $face_point[0] += $data['points'][$point]->getX() / $point_count;
@@ -195,6 +215,7 @@ public function subdivideSurfaces($factor = 1) {
195 215
                     $point_count = count($points);
196 216
                     foreach ($points as $point) {
197 217
                         $point_edges[$point][] = $edge;
  218
+
198 219
                         $edge_middle[0] += $data['points'][$point]->getX() / $point_count;
199 220
                         $edge_middle[1] += $data['points'][$point]->getY() / $point_count;
200 221
                         $edge_middle[2] += $data['points'][$point]->getZ() / $point_count;
@@ -204,7 +225,7 @@ public function subdivideSurfaces($factor = 1) {
204 225
 
205 226
                 // Calculate average of the adjacent faces
206 227
                 $average_face = array(0, 0, 0);
207  
-                $point_count = count($edge_surfaces[$edge]);
  228
+                $point_count  = count($edge_surfaces[$edge]);
208 229
                 foreach ($edge_surfaces[$edge] as $surface) {
209 230
                     $average_face[0] += $face_points[$surface]->getX() / $point_count;
210 231
                     $average_face[1] += $face_points[$surface]->getY() / $point_count;
@@ -219,18 +240,23 @@ public function subdivideSurfaces($factor = 1) {
219 240
             foreach ($data['points'] as $point => $value) {
220 241
                 // Calculate average of midpoints of adjacent edges
221 242
                 $r = array(0, 0, 0);
  243
+
222 244
                 $surfaces = array();
  245
+
223 246
                 $point_count = count($point_edges[$point]);
  247
+
224 248
                 foreach ($point_edges[$point] as $edge) {
225 249
                     $r[0] += $edge_middles[$edge][0] / $point_count;
226 250
                     $r[1] += $edge_middles[$edge][1] / $point_count;
227 251
                     $r[2] += $edge_middles[$edge][2] / $point_count;
  252
+
228 253
                     $surfaces = array_merge($surfaces, $edge_surfaces[$edge]);
229 254
                 }
230  
-                $surfaces= array_unique($surfaces);
  255
+                $surfaces = array_unique($surfaces);
231 256
 
232 257
                 // Calculate average of surrounding face points
233 258
                 $q = array(0, 0, 0);
  259
+
234 260
                 $surface_count = count($surfaces);
235 261
                 foreach ($surfaces as $surface) {
236 262
                     $q[0] += $face_points[$surface]->getX() / $surface_count;
@@ -240,6 +266,7 @@ public function subdivideSurfaces($factor = 1) {
240 266
 
241 267
                 // Create new edge point
242 268
                 $n = count($point_edges[$point]);
  269
+
243 270
                 $old_points[$point] = new Image_3D_Point(
244 271
                     ($q[0] / $n) + ((2 * $r[0]) / $n) + (($value->getX() * ($n - 3)) / $n),
245 272
                     ($q[1] / $n) + ((2 * $r[1]) / $n) + (($value->getY() * ($n - 3)) / $n),
@@ -260,12 +287,10 @@ public function subdivideSurfaces($factor = 1) {
260 287
                 // Create new polygones
261 288
                 foreach ($points as $point) {
262 289
                     $edges = array_values(array_intersect($point_edges[$point], $data['surfaces'][$surface]));
263  
-                    $this->_addPolygon(new Image_3D_Polygon(
264  
-                        $old_points[$point],
265  
-                        $edge_points[$edges[0]],
266  
-                        $face_point,
267  
-                        $edge_points[$edges[1]]
268  
-                    ));
  290
+                    $this->_addPolygon(new Image_3D_Polygon($old_points[$point],
  291
+                                                            $edge_points[$edges[0]],
  292
+                                                            $face_point,
  293
+                                                            $edge_points[$edges[1]]));
269 294
                 }
270 295
             }
271 296
 
16  Image/3D/Paintable/Object/3ds.php
@@ -38,14 +38,14 @@
38 38
 /**
39 39
  * Image_3D_Object_3ds
40 40
  *
41  
- * @category   Image
42  
- * @package    Image_3D
43  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
44  
- * @copyright  1997-2005 Kore Nordmann
45  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
46  
- * @version    Release: @package_version@
47  
- * @link       http://pear.php.net/package/PackageName
48  
- * @since      Class available since Release 0.1.0
  41
+ * @category  Image
  42
+ * @package   Image_3D
  43
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  44
+ * @copyright 1997-2005 Kore Nordmann
  45
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  46
+ * @version   Release: @package_version@
  47
+ * @link      http://pear.php.net/package/PackageName
  48
+ * @since     Class available since Release 0.1.0
49 49
  */
50 50
 class Image_3D_Object_3ds extends Image_3D_Object {
51 51
     
16  Image/3D/Paintable/Object/Cube.php
@@ -37,14 +37,14 @@
37 37
 /**
38 38
  * Image_3D_Object_Cube
39 39
  *
40  
- * @category   Image
41  
- * @package    Image_3D
42  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
43  
- * @copyright  1997-2005 Kore Nordmann
44  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
45  
- * @version    Release: @package_version@
46  
- * @link       http://pear.php.net/package/PackageName
47  
- * @since      Class available since Release 0.1.0
  40
+ * @category  Image
  41
+ * @package   Image_3D
  42
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  43
+ * @copyright 1997-2005 Kore Nordmann
  44
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  45
+ * @version   Release: @package_version@
  46
+ * @link      http://pear.php.net/package/PackageName
  47
+ * @since     Class available since Release 0.1.0
48 48
  */
49 49
 class Image_3D_Object_Cube extends Image_3D_Object {
50 50
     
186  Image/3D/Paintable/Polygon.php
@@ -36,16 +36,17 @@
36 36
 /**
37 37
  * Image_3D_Polygon
38 38
  *
39  
- * @category   Image
40  
- * @package    Image_3D
41  
- * @author     Kore Nordmann <3d@kore-nordmann.de>
42  
- * @copyright  1997-2005 Kore Nordmann
43  
- * @license    http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
44  
- * @version    Release: @package_version@
45  
- * @link       http://pear.php.net/package/PackageName
46  
- * @since      Class available since Release 0.1.0
  39
+ * @category  Image
  40
+ * @package   Image_3D
  41
+ * @author    Kore Nordmann <3d@kore-nordmann.de>
  42
+ * @copyright 1997-2005 Kore Nordmann
  43
+ * @license   http://www.gnu.org/licenses/lgpl.txt lgpl 2.1
  44
+ * @version   Release: @package_version@
  45
+ * @link      http://pear.php.net/package/PackageName
  46
+ * @since     Class available since Release 0.1.0
47 47
  */
48  
-class Image_3D_Polygon implements Image_3D_Interface_Paintable, Image_3D_Interface_Enlightenable {
  48
+class Image_3D_Polygon implements Image_3D_Interface_Paintable, Image_3D_Interface_Enlightenable
  49
+{
49 50
     
50 51
     protected $_color;
51 52
     protected $_colorCalculated;
@@ -64,11 +65,14 @@ public function __construct()
64 65
     {
65 66
         $this->_points = array();
66 67
         $this->_option = array();
67  
-        $this->_color = null;
  68
+        $this->_color  = null;
  69
+
68 70
         $this->_colorCalculated = false;
69  
-        $this->_visible = true;
70  
-        $this->_normale = null;
  71
+
  72
+        $this->_visible  = true;
  73
+        $this->_normale  = null;
71 74
         $this->_position = null;
  75
+
72 76
         $this->_boundingRect = array(null, null, null, null, null, null);
73 77
         
74 78
         if (func_num_args()) {
@@ -81,16 +85,21 @@ public function __construct()
81 85
         }
82 86
     }
83 87
 
84  
-    public function calculateColor($lights) {
85  
-        foreach ($lights as $light) $this->_color = $light->getColor($this);
  88
+    public function calculateColor($lights)
  89
+    {
  90
+        foreach ($lights as $light) {
  91
+            $this->_color = $light->getColor($this); 
  92
+        }
86 93
         $this->_color->calculateColor();
87 94
     }
88 95
     
89  
-    public function getColor() {
  96
+    public function getColor()
  97
+    {
90 98
         return $this->_color;
91 99
     }
92 100
     
93  
-    protected function _calcNormale() {
  101
+    protected function _calcNormale()
  102
+    {
94 103
         if (count($this->_points) < 3) {
95 104
             $this->_normale = new Image_3D_Vector(0, 0, 0);
96 105
             return false;
@@ -102,14 +111,20 @@ protected function _calcNormale() {
102 111
         $b1 = $this->_points[2]->getX() - $this->_points[1]->getX();
103 112
         $b2 = $this->_points[2]->getY() - $this->_points[1]->getY();
104 113
         $b3 = $this->_points[2]->getZ() - $this->_points[1]->getZ();
  114
+
105 115
         $this->_normale = new Image_3D_Vector($a2 * $b3 - $a3 * $b2, $a3 * $b1 - $a1 * $b3, $a1 * $b2 - $a2 * $b1);
106 116
         
107 117
         // Backface Culling
108  
-        if (($this->_normale->getZ() <= 0) && (@$this->_option[Image_3D::IMAGE_3D_OPTION_BF_CULLING])) $this->setInvisible();
  118
+        if (($this->_normale->getZ() <= 0) && (@$this->_option[Image_3D::IMAGE_3D_OPTION_BF_CULLING])) {
  119
+            $this->setInvisible();
  120
+        }
109 121
     }
110 122
     
111  
-    public function getNormale() {
112  
-        if (!($this->_normale instanceof Image_3D_Vector)) $this->_calcNormale();
  123
+    public function getNormale() 
  124
+    {
  125
+        if (!($this->_normale instanceof Image_3D_Vector)) {
  126
+            $this->_calcNormale();
  127
+        }
113 128
         return $this->_normale;    
114 129
     }
115 130
     
@@ -122,15 +137,20 @@ protected function _calcPosition()
122 137
             $position[2] += $point->getZ();
123 138
         }
124 139
         $count = count($this->_points);
  140
+
125 141
         $this->_position = new Image_3D_Vector($position[0] / $count, $position[1] / $count, $position[2] / $count);
126 142
     }
127 143
     
128  
-    public function getPosition() {
129  
-        if (!($this->_position instanceof Image_3D_Vector)) $this->_calcPosition();
  144
+    public function getPosition() 
  145
+    {
  146
+        if (!($this->_position instanceof Image_3D_Vector)) {
  147
+            $this->_calcPosition();
  148
+        }
130 149
         return $this->_position;    
131 150
     }
132 151
     
133  
-    public function getPolygonCount() {
  152
+    public function getPolygonCount() 
  153
+    {
134 154
         return 1;
135 155
     }
136 156
     
@@ -139,7 +159,8 @@ public function setColor(Image_3D_Color $color)
139 159
         $this->_color = $color;
140 160
     }
141 161
     
142  
-    public function isVisible() {
  162
+    public function isVisible()
  163
+    {
143 164
         return $this->isVisible();
144 165
     }
145 166
     
@@ -151,7 +172,9 @@ public function setInvisible()
151 172
     public function setOption($option, $value)
152 173
     {
153 174
         $this->_option[$option] = $value;
154  
-        foreach ($this->_points as $point) $point->setOption($option, $value);
  175
+        foreach ($this->_points as $point) {
  176
+            $point->setOption($option, $value);
  177
+        }
155 178
     }
156 179
     
157 180
     public function addPoint(Image_3D_Point $point)
@@ -159,15 +182,33 @@ public function addPoint(Image_3D_Point $point)
159 182
         $this->_points[] = $point;
160 183
 
161 184
         // Adjust bounding rectangle
162  
-        if (!isset($this->_boundingRect[0]) || ($point->getX() < $this->_boundingRect[0])) $this->_boundingRect[0] = $point->getX();
163  
-        if (!isset($this->_boundingRect[1]) || ($point->getY() < $this->_boundingRect[1])) $this->_boundingRect[1] = $point->getY();
164  
-        if (!isset($this->_boundingRect[2]) || ($point->getZ() < $this->_boundingRect[2])) $this->_boundingRect[2] = $point->getZ();
165  
-        if (!isset($this->_boundingRect[3]) || ($point->getX() > $this->_boundingRect[3])) $this->_boundingRect[3] = $point->getX();
166  
-        if (!isset($this->_boundingRect[4]) || ($point->getY() > $this->_boundingRect[4])) $this->_boundingRect[4] = $point->getY();
167  
-        if (!isset($this->_boundingRect[5]) || ($point->getZ() > $this->_boundingRect[5])) $this->_boundingRect[5] = $point->getZ();
  185
+        if (!isset($this->_boundingRect[0]) || ($point->getX() < $this->_boundingRect[0])) {
  186
+            $this->_boundingRect[0] = $point->getX();
  187
+        }
  188
+
  189
+        if (!isset($this->_boundingRect[1]) || ($point->getY() < $this->_boundingRect[1])) { 
  190
+            $this->_boundingRect[1] = $point->getY(); 
  191
+        }
  192
+
  193
+        if (!isset($this->_boundingRect[2]) || ($point->getZ() < $this->_boundingRect[2])) { 
  194
+            $this->_boundingRect[2] = $point->getZ(); 
  195
+        }
  196
+
  197
+        if (!isset($this->_boundingRect[3]) || ($point->getX() > $this->_boundingRect[3])) { 
  198
+            $this->_boundingRect[3] = $point->getX(); 
  199
+        } 
  200
+
  201
+        if (!isset($this->_boundingRect[4]) || ($point->getY() > $this->_boundingRect[4])) { 
  202
+            $this->_boundingRect[4] = $point->getY(); 
  203
+        }
  204
+
  205
+        if (!isset($this->_boundingRect[5]) || ($point->getZ() > $this->_boundingRect[5])) { 
  206
+            $this->_boundingRect[5] = $point->getZ(); 
  207
+        }
168 208
     }
169 209
     
170  
-    public function getPoints() {
  210
+    public function getPoints() 
  211
+    {
171 212
         return $this->_points;
172 213
     }
173 214
 
@@ -176,33 +217,61 @@ protected function _recalcBoundings()
176 217
         $this->_boundingRect = array(null, null, null, null, null, null);
177 218
         
178 219
         foreach ($this->_points as $point) {
179  
-            if (!isset($this->_boundingRect[0]) || ($point->getX() < $this->_boundingRect[0])) $this->_boundingRect[0] = $point->getX();
180  
-            if (!isset($this->_boundingRect[1]) || ($point->getY() < $this->_boundingRect[1])) $this->_boundingRect[1] = $point->getY();
181  
-            if (!isset($this->_boundingRect[2]) || ($point->getZ() < $this->_boundingRect[2])) $this->_boundingRect[2] = $point->getZ();
182  
-            if (!isset($this->_boundingRect[3]) || ($point->getX() > $this->_boundingRect[3])) $this->_boundingRect[3] = $point->getX();
183  
-            if (!isset($this->_boundingRect[4]) || ($point->getY() > $this->_boundingRect[4])) $this->_boundingRect[4] = $point->getY();
184  
-            if (!isset($this->_boundingRect[5]) || ($point->getZ() > $this->_boundingRect[5])) $this->_boundingRect[5] = $point->getZ();
  220
+            if (!isset($this->_boundingRect[0]) || ($point->getX() < $this->_boundingRect[0])) {
  221
+                $this->_boundingRect[0] = $point->getX();
  222
+            }
  223
+
  224
+            if (!isset($this->_boundingRect[1]) || ($point->getY() < $this->_boundingRect[1])) {
  225
+                $this->_boundingRect[1] = $point->getY();
  226
+            }
  227
+
  228
+            if (!isset($this->_boundingRect[2]) || ($point->getZ() < $this->_boundingRect[2])) {
  229
+                $this->_boundingRect[2] = $point->getZ();
  230
+            }
  231
+
  232
+            if (!isset($this->_boundingRect[3]) || ($point->getX() > $this->_boundingRect[3])) {
  233
+                $this->_boundingRect[3] = $point->getX();
  234
+            }
  235
+
  236
+            if (!isset($this->_boundingRect[4]) || ($point->getY() > $this->_boundingRect[4])) {
  237
+                $this->_boundingRect[4] = $point->getY();
  238
+            }
  239
+
  240
+            if (!isset($this->_boundingRect[5]) || ($point->getZ() > $this->_boundingRect[5])) {
  241
+                $this->_boundingRect[5] = $point->getZ();
  242
+            }
185 243
         }
186 244
     }
187 245
 
188  
-    public function transform(Image_3D_Matrix $matrix, $id = null) {
  246
+    public function transform(Image_3D_Matrix $matrix, $id = null) 
  247
+    {
189 248
         
190  
-        if ($id === null) $id = substr(md5(microtime()), 0, 8);
191  
-        foreach ($this->_points as $point) $point->transform($matrix, $id);
  249
+        if ($id === null) {
  250
+            $id = substr(md5(microtime()), 0, 8);
  251
+        }
  252
+
  253
+        foreach ($this->_points as $point) {
  254
+            $point->transform($matrix, $id);
  255
+        }
  256
+
192 257
         $this->_recalcBoundings();
193 258
     }
194 259
     
195 260
     public function getMidZ()
196 261
     {
197 262
         $z = 0;
198  
-        foreach ($this->_points as $point) $z += $point->getZ();
  263
+        foreach ($this->_points as $point) {
  264
+            $z += $point->getZ();
  265
+        }
199 266
         return $z / count($this->_points);
200 267
     }
201 268
     
202 269
     public function getMaxZ()
203 270
     {
204 271
         $z = -500;
205  
-        foreach ($this->_points as $point) $z = max($point->getZ(), $z);
  272
+        foreach ($this->_points as $point) {
  273
+            $z = max($point->getZ(), $z);
  274
+        }
206 275
         return $z;
207 276
     }
208 277
 
@@ -215,7 +284,8 @@ public function __toString()
215 284
         return $string;
216 285
     }
217 286
 
218  
-    public function distance(Image_3D_Line $line) {
  287
+    public function distance(Image_3D_Line $line) 
  288
+    {
219 289
         // Calculate parameters for plane
220 290
         $normale = $this->getNormale();
221 291
 
@@ -229,22 +299,31 @@ public function distance(Image_3D_Line $line) {
229 299
 
230 300
         // Calculate wheather and where line cuts the polygons plane
231 301
         $lineDirection = $line->getDirection();
  302
+
232 303
         $denominator = -(   $A * $line->getX() +
233 304
                             $B * $line->getY() +
234 305
                             $C * $line->getZ() +
235 306
                             $D);
  307
+
236 308
         $numerator = (      $A * $lineDirection->getX() +
237 309
                             $B * $lineDirection->getY() +
238 310
                             $C * $lineDirection->getZ());
239 311
 
240 312
         // Nu cut, when denomintor equals 0 (parallel plane)
241  
-        if ((int) ($denominator * 100000) === 0) return false;
242  
-        if ((int) ($numerator * 100000) === 0) return false;
  313
+        if ((int) ($denominator * 100000) === 0) {
  314
+            return false;
  315
+        }
  316
+
  317
+        if ((int) ($numerator * 100000) === 0) {
  318
+            return false;
  319
+        }
243 320
         
244 321
         $t = $denominator / $numerator;
245 322
 
246 323
         // No cut, when $t < 0 (plane is behind the camera)
247  
-        if ($t <= 0) return false;
  324
+        if ($t <= 0) {
  325
+            return false;
  326
+        }
248 327
 
249 328
         // TODO: Perhaps add max distance check with unified normale vector
250 329
 
@@ -266,14 +345,13 @@ public function distance(Image_3D_Line $line) {
266 345
         foreach ($this->_points as $nr => $point) {
267 346
             $nextPoint = $this->_points[($nr + 1) % count($this->_points)];
268 347
             
269  
-            $edge = new Image_3D_Vector(
270  
-                $nextPoint->getX() - $point->getX(),
271  
-                $nextPoint->getY() - $point->getY(),
272  
-                $nextPoint->getZ() - $point->getZ());
273  
-            $v = new Image_3D_Vector(
274  
-                $cuttingPoint->getX() - $point->getX(),
275  
-                $cuttingPoint->getY() - $point->getY(),
276  
-                $cuttingPoint->getZ() - $point->getZ());
  348
+            $edge = new Image_3D_Vector($nextPoint->getX() - $point->getX(),
  349
+                                        $nextPoint->getY() - $point->getY(),
  350
+                                        $nextPoint->getZ() - $point->getZ());
  351
+
  352
+            $v = new Image_3D_Vector($cuttingPoint->getX() - $point->getX(),
  353
+                                     $cuttingPoint->getY() - $point->getY(),
  354
+                                     $cuttingPoint->getZ() - $point->getZ());
277 355
             
278 356
             $scalar = $edge->crossProduct($v)->scalar($normale);
279 357
 

0 notes on commit 841c60a

Please sign in to comment.
Something went wrong with that request. Please try again.