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 ();
24 virtual QPointF toQPointF();
27 class ConvexPolygon:public QPolygonF
31 ConvexPolygon (QPolygonF p);
33 QPointF centroid() const;
35 std::string toStdString ();
36 Vector at (const int &i) const ;
37 virtual void translate ( const Vector &offset );
38 virtual void translate ( qreal dx, qreal dy );
44 class PolygonCollisionResult {
46 // Are the polygons going to intersect forward in time?
49 // Are the polygons currently intersecting?
52 // The translation to apply to the first polygon to push the polygons apart.
53 QPointF minTranslation;
57 void projectPolygon(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ;
59 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
60 PolygonCollisionResult polygonCollision(ConvexPolygon polygonA,
61 ConvexPolygon polygonB, Vector velocity);