6 QRectF addBBox(QRectF r1, QRectF r2);
7 bool isInBox(const QPointF &p, const QRectF &box);
10 class Vector:public QPointF
14 Vector (const QPointF &p);
15 Vector (qreal x, qreal y);
17 friend inline bool operator==(const Vector &v1, const Vector &v2 )
18 { return v1.x()==v2.x() && v1.y()==v2.y(); }
20 virtual void normalize ();
21 virtual qreal dotProduct (const QPointF &b);
22 virtual void scale (const qreal &f);
23 virtual void invert ();
26 class ConvexPolygon:public QPolygonF
30 ConvexPolygon (QPolygonF p);
32 QPointF centroid() const;
34 std::string toStdString ();
35 Vector at (const int &i) const ;
36 virtual void translate ( const Vector &offset );
37 virtual void translate ( qreal dx, qreal dy );
43 class PolygonCollisionResult {
45 // Are the polygons going to intersect forward in time?
48 // Are the polygons currently intersecting?
51 // The translation to apply to the first polygon to push the polygons apart.
52 QPointF minTranslation;
56 void projectPolygon(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ;
58 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
59 PolygonCollisionResult polygonCollision(ConvexPolygon polygonA,
60 ConvexPolygon polygonB, Vector velocity);