Tue, 19 Jun 2018 22:45:10 +0300
fixed generation of disc negatives
src/generics/functions.h | file | annotate | diff | comparison | revisions | |
src/primitives.cpp | file | annotate | diff | comparison | revisions |
--- a/src/generics/functions.h Tue Jun 19 22:00:46 2018 +0300 +++ b/src/generics/functions.h Tue Jun 19 22:45:10 2018 +0300 @@ -118,24 +118,13 @@ } /* - * Extracts the sign of x. + * Extracts the sign of 'value'. + * From: https://stackoverflow.com/q/1903954 */ template<typename T> -T sign(T x) +int sign(T value) { - if (isZero(x)) - return {}; - else - return x / qAbs(x); -} - -template<> -inline int sign(int x) -{ - if (x == 0) - return 0; - else - return x / qAbs(x); + return (0 < value) - (value < 0); } /*
--- a/src/primitives.cpp Tue Jun 19 22:00:46 2018 +0300 +++ b/src/primitives.cpp Tue Jun 19 22:45:10 2018 +0300 @@ -368,7 +368,8 @@ { LDTriangle* segment = model.emplace<LDTriangle>(); segment->setColor(MainColor); - segment->setVertex(0, {(circle[i].x1() >= 0.0) ? 1.0 : -1.0, 0.0, (circle[i].y1() >= 0.0) ? 1.0 : -1.0}); + double angle = (i + 0.5) * 2.0 * pi / divisions; + segment->setVertex(0, {double(sign(cos(angle))), 0.0, double(sign(sin(angle)))}); segment->setVertex(1, {circle[i].x2(), 0.0, circle[i].y2()}); segment->setVertex(2, {circle[i].x1(), 0.0, circle[i].y1()}); }