X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=geometry.h;fp=geometry.h;h=f863a7ca4c5c4da94fe1bff1e85f25bb328f2f96;hb=2f79edb68ae955de3c3118a7f9181c7a1f3b0d72;hp=0000000000000000000000000000000000000000;hpb=eeb718b059f8b14807b976ae6410a3021b2d4576;p=vym diff --git a/geometry.h b/geometry.h new file mode 100644 index 0000000..f863a7c --- /dev/null +++ b/geometry.h @@ -0,0 +1,34 @@ +#ifndef GEOMETRY_H +#define GEOMETRY_H + +#include +#include +#include + +QRectF addBBox(QRectF r1, QRectF r2); +bool inBox(const QPointF &p, const QRectF &box); + +QPointF normalize (const QPointF &p); + + +qreal dotProduct (const QPointF &a, const QPointF &b); + +class PolygonCollisionResult { +public: + // Are the polygons going to intersect forward in time? + bool willIntersect; + + // Are the polygons currently intersecting? + bool intersect; + + // The translation to apply to the first polygon to push the polygons apart. + QPointF minTranslation; +}; + + +void ProjectPolygon(QPointF axis, QPolygonF polygon, qreal &min, qreal &max) ; +qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB); +PolygonCollisionResult PolygonCollision(QPolygonF polygonA, + QPolygonF polygonB, QPointF velocity); + +#endif