]> git.tdb.fi Git - libs/math.git/commitdiff
Take care not to count initialization values when finding min/max
authorMikko Rasa <tdb@tdb.fi>
Thu, 23 May 2013 19:26:28 +0000 (22:26 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 23 May 2013 19:26:28 +0000 (22:26 +0300)
source/geometry/transformedshape.h

index 84e182c6cdd5d588245c26fc7e6387ad8829b66c..f214e4bb1aa9c578308088f2475879debc726378 100644 (file)
@@ -88,10 +88,18 @@ inline BoundingBox<T, D> TransformedShape<T, D>::get_axis_aligned_bounding_box()
 
                point = transformation.transform(point);
 
-               for(unsigned j=0; j<D; ++j)
+               if(i==0)
+               {
+                       min_pt = point;
+                       max_pt = point;
+               }
+               else
                {
-                       min_pt[j] = std::min(min_pt[j], point[j]);
-                       max_pt[j] = std::max(max_pt[j], point[j]);
+                       for(unsigned j=0; j<D; ++j)
+                       {
+                               min_pt[j] = std::min(min_pt[j], point[j]);
+                               max_pt[j] = std::max(max_pt[j], point[j]);
+                       }
                }
        }