From 8b0784f26c363ed1a6fc592035288cbbbd2d9002 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 28 Nov 2016 17:34:52 +0100 Subject: [PATCH] Added a free "cross product" function to Pointf (thinking the Pointf is really a vector in this case). Made the == operator inline. --- xs/src/libslic3r/Point.cpp | 6 ------ xs/src/libslic3r/Point.hpp | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/Point.cpp b/xs/src/libslic3r/Point.cpp index 8b71746e0..2ee5dabdd 100644 --- a/xs/src/libslic3r/Point.cpp +++ b/xs/src/libslic3r/Point.cpp @@ -12,12 +12,6 @@ Point::Point(double x, double y) this->y = lrint(y); } -bool -Point::operator==(const Point& rhs) const -{ - return this->coincides_with(rhs); -} - std::string Point::wkt() const { diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index 2cf046133..a69f8d9f8 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -36,7 +36,7 @@ class Point static Point new_scale(coordf_t x, coordf_t y) { return Point(scale_(x), scale_(y)); }; - bool operator==(const Point& rhs) const; + bool operator==(const Point& rhs) const { return this->x == rhs.x && this->y == rhs.y; } std::string wkt() const; std::string dump_perl() const; void scale(double factor); @@ -105,6 +105,8 @@ class Pointf inline Pointf operator+(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x + point2.x, point1.y + point2.y); } inline Pointf operator-(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x - point2.x, point1.y - point2.y); } inline Pointf operator*(double scalar, const Pointf& point2) { return Pointf(scalar * point2.x, scalar * point2.y); } +inline Pointf operator*(const Pointf& point2, double scalar) { return Pointf(scalar * point2.x, scalar * point2.y); } +inline coordf_t cross(const Pointf &v1, const Pointf &v2) { return v1.x * v2.y - v1.y * v2.x; } class Pointf3 : public Pointf {