7 qreal distance (const QPointF &p, const QPointF &q);
10 QRectF addBBox(QRectF r1, QRectF r2);
11 QSize addBBoxSize(QSize s1, QSize s2);
12 bool isInBox(const QPointF &p, const QRectF &box);
14 class Vector:public QPointF
18 Vector (const QPointF &p);
19 Vector (qreal x, qreal y);
22 friend inline bool operator==(const Vector &v1, const Vector &v2 )
23 { return v1.x()==v2.x() && v1.y()==v2.y(); }
26 virtual void normalize ();
27 virtual qreal dotProduct (const QPointF &b);
28 virtual void scale (const qreal &f);
29 virtual void invert ();
30 virtual QPointF toQPointF();
33 class ConvexPolygon:public QPolygonF
37 ConvexPolygon (QPolygonF p);
38 virtual ~ConvexPolygon();
40 QPointF centroid() const;
42 std::string toStdString ();
43 Vector at (const int &i) const ;
44 virtual void translate ( const Vector &offset );
45 virtual void translate ( qreal dx, qreal dy );
51 class PolygonCollisionResult {
53 // Are the polygons going to intersect forward in time?
56 // Are the polygons currently intersecting?
59 // The translation to apply to the first polygon to push the polygons apart.
60 QPointF minTranslation;
64 void projectPolygon(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ;
66 qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB);
67 PolygonCollisionResult polygonCollision(ConvexPolygon polygonA,
68 ConvexPolygon polygonB, Vector velocity);