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 {
17 Vector(const QPointF &p);
18 Vector(qreal x, qreal y);
21 friend inline bool operator==(const Vector &v1, const Vector &v2)
23 return v1.x() == v2.x() && v1.y() == v2.y();
27 virtual void normalize();
28 virtual qreal dotProduct(const QPointF &b);
29 virtual void scale(const qreal &f);
30 virtual void invert();
31 virtual QPointF toQPointF();
34 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);
52 class PolygonCollisionResult {
54 // Are the polygons going to intersect forward in time?
57 // Are the polygons currently intersecting?
60 // The translation to apply to the first polygon to push the polygons apart.
61 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,