From 30b579c8ce41c105392c436880612a0e9057880f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 9 Oct 2024 09:26:26 -0400 Subject: partition collisions --- balls.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'balls.h') diff --git a/balls.h b/balls.h index 3d0202c..b908183 100644 --- a/balls.h +++ b/balls.h @@ -1,3 +1,14 @@ +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace oneapi::tbb; +using namespace oneapi::tbb::flow; + typedef struct { double x, y; } Point; @@ -22,6 +33,44 @@ typedef struct { Color color; } Ball; +typedef continue_node node_t; +typedef const continue_msg & msg_t; + +class Collision { +public: + Ball *b1, *b2; + + Collision(Ball *_b1, Ball *_b2) { + b1 = _b1; + b2 = _b2; + } + + friend bool operator<(const Collision& a, const Collision& b) { + return a.b1 < b.b1 || a.b2 < b.b2; + } + + friend bool operator==(const Collision& a, const Collision& b) { + return a.b1 == b.b1 && a.b2 == b.b2; + } + + friend ostream &operator<<(ostream& os, Collision const & c) { + return os << "(" << c.b1 << ", " << c.b2 << ")"; + } +}; + +class CollisionGraph { +private: + graph g; + node_t root; + vector>> layers; + +public: + CollisionGraph(void); + void run(); +}; + +vector> partitionCollisions(vector balls); + Point addPt(Point p, Point q); Point subPt(Point p, Point q); Point ptAddVec(Point p, Vector v); -- cgit v1.2.3