1.1 --- a/geometry.h Mon Apr 20 10:42:05 2009 +0000
1.2 +++ b/geometry.h Mon Aug 24 14:39:07 2009 +0000
1.3 @@ -1,18 +1,32 @@
1.4 -#ifndef GEOMETRY_H
1.5 -#define GEOMETRY_H
1.6 +#ifndef GEOMETRY
1.7 +#define GEOMETRY
1.8
1.9 -#include <QPointF>
1.10 -#include <QRectF>
1.11 #include <QPolygonF>
1.12
1.13 QRectF addBBox(QRectF r1, QRectF r2);
1.14 bool isInBox(const QPointF &p, const QRectF &box);
1.15
1.16 +class ConvexPolygon:public QPolygonF
1.17 +{
1.18 +public:
1.19 + ConvexPolygon ();
1.20 + ConvexPolygon (QPolygonF p);
1.21 + void calcCentroid() ;
1.22 + QPointF centroid() const;
1.23 + qreal weight() const;
1.24 +private:
1.25 + QPointF _centroid;
1.26 + qreal _area;
1.27 +};
1.28 +
1.29 QPointF normalize (const QPointF &p);
1.30
1.31
1.32 qreal dotProduct (const QPointF &a, const QPointF &b);
1.33
1.34 +QPointF scale (const QPointF &v,const qreal &f);
1.35 +QPointF invert (const QPointF &v);
1.36 +
1.37 class PolygonCollisionResult {
1.38 public:
1.39 // Are the polygons going to intersect forward in time?
1.40 @@ -26,9 +40,10 @@
1.41 };
1.42
1.43
1.44 -void ProjectPolygon(QPointF axis, QPolygonF polygon, qreal &min, qreal &max) ;
1.45 +void projectPolygon(QPointF axis, QPolygonF polygon, qreal &min, qreal &max) ;
1.46 +
1.47 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
1.48 -PolygonCollisionResult PolygonCollision(QPolygonF polygonA,
1.49 +PolygonCollisionResult polygonCollision(QPolygonF polygonA,
1.50 QPolygonF polygonB, QPointF velocity);
1.51
1.52 -#endif
1.53 +#endif
1.54 \ No newline at end of file