diff --git a/src/datatypes.h b/src/datatypes.h index e5a5d15..b1b5e5d 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -1,5 +1,6 @@ #pragma once +#include #include // 2D Vectors @@ -14,7 +15,19 @@ class Vec2D{ T y = 0; T dist(Vec2D* v) { return sqrt(pow((v->x - x), 2) + pow((v->y - y), 2));}; T length() { return sqrt(pow(x, 2) + pow(y, 2));}; - + + T angle(Vec2D &v){ + T angle = atan2(v.y, v.x) - atan2(y,x); + if(angle > M_PI) angle -= M_PI_2; + if(angle < -M_PI) angle += M_PI_2; + return angle; + //return acos(dot(v)); + }; + + T dot(Vec2D &v){ + return (x*v.x) + (y*v.y); + }; + Vec2D& norm() { return *this * (1.0/length());}; Vec2D& operator=(const Vec2D& vec){ @@ -64,3 +77,21 @@ struct Color{ int g; int b; }; + +/*template */ +/*bool contains(T X, T Y) {*/ +/* for (unsigned int i=0;idraw(circle); }; };