diff --git a/src/Mod/PartDesign/App/FeatureHelix.cpp b/src/Mod/PartDesign/App/FeatureHelix.cpp index d4f5b4cb5b..7ef8ecf189 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.cpp +++ b/src/Mod/PartDesign/App/FeatureHelix.cpp @@ -23,37 +23,26 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include # include -# include -# include +# include +# include +# include +# include # include # include # include -# include +# include +# include +# include +# include +# include +# include # include # include #endif # include # include -# include # include # include # include @@ -411,17 +400,17 @@ TopoDS_Shape Helix::generateHelixPath(double startOffset0) double angle = Angle.getValue(); double growth = Growth.getValue(); - if (angle < Precision::Confusion() && angle > -Precision::Confusion()) + if (fabs(angle) < Precision::Confusion()) angle = 0.0; // get revolve axis - Base::Vector3d b = Base.getValue(); - gp_Pnt pnt(b.x, b.y, b.z); - Base::Vector3d v = Axis.getValue(); - gp_Dir dir(v.x, v.y, v.z); + Base::Vector3d baseVector = Base.getValue(); + gp_Pnt pnt(baseVector.x, baseVector.y, baseVector.z); + Base::Vector3d axisVector = Axis.getValue(); + gp_Dir dir(axisVector.x, axisVector.y, axisVector.z); Base::Vector3d normal = getProfileNormal(); - Base::Vector3d start = v.Cross(normal); // pointing towards the desired helix start point. + Base::Vector3d start = axisVector.Cross(normal); // pointing towards the desired helix start point. // if our axis is (nearly) aligned with the profile's normal, we're only interested in the "twist" // of the helix. The actual starting point, and thus the radius, isn't important as long as it's @@ -443,14 +432,14 @@ TopoDS_Shape Helix::generateHelixPath(double startOffset0) // The factor of 100 below ensures that profile size is small compared to the curvature of the helix. // This improves the issue reported in https://forum.freecadweb.org/viewtopic.php?f=10&t=65048 - double axisOffset = 100 * (profileCenter * start - b * start); - double startOffset = startOffset0 + profileCenter * v - b * v; + double axisOffset = 100 * (profileCenter * start - baseVector * start); + double startOffset = startOffset0 + profileCenter * axisVector - baseVector * axisVector; double radius = std::fabs(axisOffset); bool turned = axisOffset < 0; if (radius < Precision::Confusion()) { // in this case ensure that axis is not in the sketch plane - if (std::fabs(v * normal) < Precision::Confusion()) + if (fabs(axisVector * normal) < Precision::Confusion()) throw Base::ValueError("Error: Result is self intersecting"); radius = 1000.0; //fallback to radius 1000 }