Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-03-23 20:51:10 +0300
committerbubnikv <bubnikv@gmail.com>2020-03-23 21:20:54 +0300
commit580d739d6f377fcf76456051e1816aae2fb35bad (patch)
tree9c266d187679ba812cd0bc132ffc27fc36ab3c5c /src/libslic3r/Point.hpp
parent22d9fcb27f0fba76e4fffe86fde4034ea0b8e32f (diff)
parentd5bcddeed333e6be567de517bc22c69fc5559b7e (diff)
Merging version_2.2.0 final into stable
Merge commit 'd5bcddeed333e6be567de517bc22c69fc5559b7e' into stable
Diffstat (limited to 'src/libslic3r/Point.hpp')
-rw-r--r--src/libslic3r/Point.hpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp
index 9631ba975..dced5c02a 100644
--- a/src/libslic3r/Point.hpp
+++ b/src/libslic3r/Point.hpp
@@ -92,9 +92,9 @@ public:
Point(coord_t x, coord_t y) : Vec2crd(x, y) {}
Point(int64_t x, int64_t y) : Vec2crd(coord_t(x), coord_t(y)) {} // for Clipper
Point(double x, double y) : Vec2crd(coord_t(lrint(x)), coord_t(lrint(y))) {}
- Point(const Point& rhs) { *this = rhs; }
- explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(lrint(rhs.x())), coord_t(lrint(rhs.y()))) {}
- // This constructor allows you to construct Point from Eigen expressions
+ Point(const Point &rhs) { *this = rhs; }
+ explicit Point(const Vec2d& rhs) : Vec2crd(coord_t(lrint(rhs.x())), coord_t(lrint(rhs.y()))) {}
+ // This constructor allows you to construct Point from Eigen expressions
template<typename OtherDerived>
Point(const Eigen::MatrixBase<OtherDerived> &other) : Vec2crd(other) {}
static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); }
@@ -128,6 +128,36 @@ public:
Point projection_onto(const Line &line) const;
};
+inline bool is_approx(const Point &p1, const Point &p2, coord_t epsilon = coord_t(SCALED_EPSILON))
+{
+ Point d = (p2 - p1).cwiseAbs();
+ return d.x() < epsilon && d.y() < epsilon;
+}
+
+inline bool is_approx(const Vec2f &p1, const Vec2f &p2, float epsilon = float(EPSILON))
+{
+ Vec2f d = (p2 - p1).cwiseAbs();
+ return d.x() < epsilon && d.y() < epsilon;
+}
+
+inline bool is_approx(const Vec2d &p1, const Vec2d &p2, double epsilon = EPSILON)
+{
+ Vec2d d = (p2 - p1).cwiseAbs();
+ return d.x() < epsilon && d.y() < epsilon;
+}
+
+inline bool is_approx(const Vec3f &p1, const Vec3f &p2, float epsilon = float(EPSILON))
+{
+ Vec3f d = (p2 - p1).cwiseAbs();
+ return d.x() < epsilon && d.y() < epsilon && d.z() < epsilon;
+}
+
+inline bool is_approx(const Vec3d &p1, const Vec3d &p2, double epsilon = EPSILON)
+{
+ Vec3d d = (p2 - p1).cwiseAbs();
+ return d.x() < epsilon && d.y() < epsilon && d.z() < epsilon;
+}
+
namespace int128 {
// Exact orientation predicate,
// returns +1: CCW, 0: collinear, -1: CW.