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(); }
22 virtual void normalize ();
23 virtual qreal dotProduct (const QPointF &b);
24 virtual void scale (const qreal &f);
25 virtual void invert ();
26 virtual QPointF toQPointF();
29 class ConvexPolygon:public QPolygonF
33 ConvexPolygon (QPolygonF p);
35 QPointF centroid() const;
37 std::string toStdString ();
38 Vector at (const int &i) const ;
39 virtual void translate ( const Vector &offset );
40 virtual void translate ( qreal dx, qreal dy );
46 class PolygonCollisionResult {
48 // Are the polygons going to intersect forward in time?
51 // Are the polygons currently intersecting?
54 // The translation to apply to the first polygon to push the polygons apart.
55 QPointF minTranslation;
59 void projectPolygon(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ;
61 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
62 PolygonCollisionResult polygonCollision(ConvexPolygon polygonA,
63 ConvexPolygon polygonB, Vector velocity);