diff options
author | bubnikv <bubnikv@gmail.com> | 2018-07-16 18:07:49 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-07-16 18:07:49 +0300 |
commit | 6dc1bf5c08b7935dfbc55d35dea31148d09732f8 (patch) | |
tree | 862e4d4149e6cd7fceb03208c3f3bcbfa1625301 /xs/src/libslic3r/Point.hpp | |
parent | 0bbd1dbc4f80ee4909f84d91931c13d757ba0af7 (diff) | |
parent | d99b484ac6e67f00666530a1d7b78e7506e2ce6c (diff) |
Merge branch 'master' into stable
Diffstat (limited to 'xs/src/libslic3r/Point.hpp')
-rw-r--r-- | xs/src/libslic3r/Point.hpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index 6c9096a3d..a52cdceb6 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -238,6 +238,11 @@ inline coordf_t dot(const Pointf &v1, const Pointf &v2) { return v1.x * v2.x + v inline coordf_t dot(const Pointf &v) { return v.x * v.x + v.y * v.y; } inline double length(const Vectorf &v) { return sqrt(dot(v)); } inline double l2(const Vectorf &v) { return dot(v); } +inline Vectorf normalize(const Vectorf& v) +{ + coordf_t len = ::sqrt(sqr(v.x) + sqr(v.y)); + return (len != 0.0) ? 1.0 / len * v : Vectorf(0.0, 0.0); +} class Pointf3 : public Pointf { |