+ replace insecure x/fabs(x) with sgn function

This commit is contained in:
wmayer 2016-03-24 11:07:30 +01:00
parent 368cd7b731
commit 05ed514bcf

View File

@ -34,6 +34,7 @@
#include <boost/math/special_functions/fpclassify.hpp> #include <boost/math/special_functions/fpclassify.hpp>
#include <Base/Console.h> #include <Base/Console.h>
#include <Base/Exception.h> #include <Base/Exception.h>
#include <Base/Tools.h>
#include <Gui/Action.h> #include <Gui/Action.h>
#include <Gui/Application.h> #include <Gui/Application.h>
@ -4721,15 +4722,17 @@ public:
float dy = onSketchPos.fY - StartPos.fY; float dy = onSketchPos.fY - StartPos.fY;
lx=0;ly=0;a=0; lx=0;ly=0;a=0;
double rev = 0;
if (fabs(dx) > fabs(dy)) { if (fabs(dx) > fabs(dy)) {
lx = dx; lx = dx;
r = dy; r = dy;
rev = dx/fabs(dx); rev = Base::sgn(dx);
}else{ }
else {
ly = dy; ly = dy;
r = dx; r = dx;
a = 8; a = 8;
rev = dy/fabs(dy); rev = Base::sgn(dy);
} }
for (int i=0; i < 17; i++) { for (int i=0; i < 17; i++) {
@ -4881,7 +4884,7 @@ public:
protected: protected:
BoxMode Mode; BoxMode Mode;
Base::Vector2D StartPos; Base::Vector2D StartPos;
double lx,ly,r,a,rev; double lx,ly,r,a;
std::vector<Base::Vector2D> EditCurve; std::vector<Base::Vector2D> EditCurve;
std::vector<AutoConstraint> sugConstr1, sugConstr2; std::vector<AutoConstraint> sugConstr1, sugConstr2;
}; };