X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=geometry.h;fp=geometry.h;h=0000000000000000000000000000000000000000;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=a694a575be300935ed66a30688ed906ff07f8ca6;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/geometry.h b/geometry.h deleted file mode 100644 index a694a57..0000000 --- a/geometry.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef GEOMETRY -#define GEOMETRY - -#include - -namespace Geometry { - qreal distance (const QPointF &p, const QPointF &q); -}; - -QRectF addBBox(QRectF r1, QRectF r2); -QSize addBBoxSize(QSize s1, QSize s2); -bool isInBox(const QPointF &p, const QRectF &box); - -class Vector:public QPointF -{ -public: - Vector (); - Vector (const QPointF &p); - Vector (qreal x, qreal y); - virtual ~Vector (); - - friend inline bool operator==(const Vector &v1, const Vector &v2 ) - { return v1.x()==v2.x() && v1.y()==v2.y(); } - - bool isNull(); - virtual void normalize (); - virtual qreal dotProduct (const QPointF &b); - virtual void scale (const qreal &f); - virtual void invert (); - virtual QPointF toQPointF(); -}; - -class ConvexPolygon:public QPolygonF -{ -public: - ConvexPolygon (); - ConvexPolygon (QPolygonF p); - virtual ~ConvexPolygon(); - void calcCentroid() ; - QPointF centroid() const; - qreal weight() const; - std::string toStdString (); - Vector at (const int &i) const ; - virtual void translate ( const Vector &offset ); - virtual void translate ( qreal dx, qreal dy ); -private: - Vector _centroid; - qreal _area; -}; - -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(Vector axis, ConvexPolygon polygon, qreal &min, qreal &max) ; - -qreal intervalDistance(qreal minA, qreal maxA, qreal minB, qreal maxB); -PolygonCollisionResult polygonCollision(ConvexPolygon polygonA, - ConvexPolygon polygonB, Vector velocity); - -#endif \ No newline at end of file