new helper methods

adjusted wall intersection
This commit is contained in:
2018-07-22 17:32:44 +02:00
parent 8ea7b7f3b6
commit 083a1c2cf2
5 changed files with 132 additions and 111 deletions

View File

@@ -44,6 +44,7 @@ struct Point2 {
bool operator != (const Point2& o) const {return x!=o.x || y!=o.y;}
bool eq (const Point2& o, const float delta) const { return eq(x,o.x,delta) && eq(y,o.y,delta); }
Point2 perpendicular() const {return Point2(-y, x);}
@@ -66,6 +67,11 @@ struct Point2 {
return "(" + std::to_string(x) + "," + std::to_string(y) + ")";
}
private:
static inline bool eq(const float a, const float b, const float delta) {return std::abs(a-b) <= delta;}
static inline bool ne(const float a, const float b, const float delta) {return std::abs(a-b) > delta;}
};
inline float dot(const Point2 p1, const Point2 p2) {