diff -r 78ba80b54bc4 -r d85834ad8c54 geometry.cpp --- a/geometry.cpp Tue Aug 18 12:39:07 2009 +0000 +++ b/geometry.cpp Mon Aug 24 14:39:07 2009 +0000 @@ -1,11 +1,12 @@ #include "geometry.h" #include -#include #include "misc.h" +#include using namespace std; + QRectF addBBox(QRectF r1, QRectF r2) { // Find smallest QRectF containing given rectangles @@ -45,6 +46,50 @@ return false; } +ConvexPolygon::ConvexPolygon () +{ +} + +ConvexPolygon::ConvexPolygon (QPolygonF p):QPolygonF (p) +{ +} + +void ConvexPolygon::calcCentroid() +{ + // Calculate area and centroid + // http://en.wikipedia.org/wiki/Centroid + qreal cx,cy,p; + cx=cy=0; + _area=0; + + append (at(0)); + for (int i=0;i max) max = d; - } + // cout << "p="< 0) - result.intersect = false; - else - result.intersect = true; + qreal d = intervalDistance(minA, maxA, minB, maxB); + if (d > 0) result.intersect = false; - // ===== 2. Now find if the polygons *will* intersect ===== + // ===== 2. Now find if the polygons *will* intersect ===== // Project the velocity on the current axis @@ -181,30 +234,25 @@ minA += velocityProjection; else maxA += velocityProjection; - // Do the same test as above for the new projection - qreal d = intervalDistance(minA, maxA, minB, maxB); - if (d > 0) result.willIntersect = false; + // d = intervalDistance(minA, maxA, minB, maxB); + //if (d > 0) result.willIntersect = false; /* - */ cout <<" "; - cout <<"minA="<