6 QRectF addBBox(QRectF r1, QRectF r2);
7 bool isInBox(const QPointF &p, const QRectF &box);
8 qreal distance (const QPointF &p, const QPointF &q);
11 class Vector:public QPointF
15 Vector (const QPointF &p);
16 Vector (qreal x, qreal y);
18 friend inline bool operator==(const Vector &v1, const Vector &v2 )
19 { return v1.x()==v2.x() && v1.y()==v2.y(); }
21 virtual void normalize ();
22 virtual qreal dotProduct (const QPointF &b);
23 virtual void scale (const qreal &f);
24 virtual void invert ();
25 virtual QPointF toQPointF();
28 class ConvexPolygon:public QPolygonF
32 ConvexPolygon (QPolygonF p);
34 QPointF centroid() const;
36 std::string toStdString ();
37 Vector at (const int &i) const ;
38 virtual void translate ( const Vector &offset );
39 virtual void translate ( qreal dx, qreal dy );
45 class PolygonCollisionResult {
47 // Are the polygons going to intersect forward in time?
50 // Are the polygons currently intersecting?
53 // The translation to apply to the first polygon to push the polygons apart.
54 QPointF minTranslation;
58 void projectPolygon(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ;
60 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
61 PolygonCollisionResult polygonCollision(ConvexPolygon polygonA,
62 ConvexPolygon polygonB, Vector velocity);