Sketcher Arc Of Hyperbola Broken?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
UR_
Posts: 989
Joined: Tue Jan 03, 2017 8:42 pm

Sketcher Arc Of Hyperbola Broken?

Postby UR_ » Wed Oct 16, 2019 3:04 pm

Screenshot 001.png
Screenshot 001.png (34.56 KiB) Viewed 229 times

Trying to use this nice function, but no luck :?

Always get these NaNs :o


App.getDocument('Unnamed').getObject('Sketch').addGeometry(Part.ArcOfHyperbola(Part.Hyperbola(App.Vector(nan,nan,0),App.Vector(163.858917,117.976585,0),App.Vector(185.834732,69.798813,0)),nan,nan),False)



Traceback (most recent call last):
File "<string>", line 1, in <module>
<class 'NameError'>: name 'nan' is not defined
name 'nan' is not defined



version:
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18528 (Git)
Build type: Release
Branch: master
Hash: 891f8953fe858d41600b41a62ebde48f91b0526a
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
User avatar
bejant
Posts: 5933
Joined: Thu Jul 11, 2013 3:06 pm

Re: Sketcher Arc Of Hyperbola Broken?

Postby bejant » Wed Oct 16, 2019 3:56 pm

Confirmed on the version below (I guess it's been broken for a while).

OS: Ubuntu 16.04.6 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1. dated 2019-04-30
Build type: Release
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
hammax
Posts: 866
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee

Re: Sketcher Arc Of Hyperbola Broken?

Postby hammax » Wed Oct 16, 2019 4:20 pm

… here it works also (after some faulty trials!)

Hyperbel.PNG
Hyperbel.PNG (10.29 KiB) Viewed 206 times
Attachments
Hyperbola.FCStd
(7.28 KiB) Downloaded 5 times
User avatar
pl7i92LCNC
Posts: 209
Joined: Tue Mar 12, 2019 3:03 pm
Location: RLP DE

Re: Sketcher Arc Of Hyperbola Broken?

Postby pl7i92LCNC » Wed Oct 16, 2019 4:38 pm

the appimage is ok wores fine
FreeCAD_0.19-18353-Linux-Conda_Py3Qt5_glibc2.12-x86_64.AppImage
wmayer
Site Admin
Posts: 14873
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher Arc Of Hyperbola Broken?

Postby wmayer » Wed Oct 16, 2019 8:46 pm

For me it works when you select carefully the points of the hyperbola. However I can also make it fail if I select the second helper line to be orthogonal to the first line. In this case the formula in DrawSketchHandlerArcOfHyperbola::releaseButton fails:

Code: Select all

double angleatstartingpoint = acosh(((startingPoint.x-centerPoint.x)*cos(phi)+(startingPoint.y-centerPoint.y)*sin(phi))/a);
The argument of acosh() seems to become negative and thus the result gives a NaN (not-a-number). When building the Python string with the broken number then it adds nan to the expression and thus leads to an error because nan is not a defined identifier.

Here the exception handling should be improved by checking the values beforehand and in case of NaN an error should be reported:
git commit eb6a405c1
UR_
Posts: 989
Joined: Tue Jan 03, 2017 8:42 pm

Re: Sketcher Arc Of Hyperbola Broken?

Postby UR_ » Thu Oct 17, 2019 7:44 am

wmayer wrote:
Wed Oct 16, 2019 8:46 pm
git commit eb6a405c1

Code: Select all

double endAngle = atanh( (((endPoint.y-centerPoint.y)*cos(phi)-(endPoint.x-centerPoint.x)*sin(phi))*a) /
                                         (((endPoint.x-centerPoint.x)*cos(phi)+(endPoint.y-centerPoint.y)*sin(phi))*b)  );

if b becomes zero, expression becomes inf


Should be caught too :?

Code: Select all

            if (boost::math::isnan(startAngle) || boost::math::isnan(endAngle)) {
                sketchgui->purgeHandler();
                Base::Console().Error("Cannot create arc of hyperbola from invalid angles, try again!\n");
                return false;
            }
wmayer
Site Admin
Posts: 14873
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher Arc Of Hyperbola Broken?

Postby wmayer » Thu Oct 17, 2019 8:52 am

if b becomes zero, expression becomes inf
If b becomes zero endAngle becomes NaN. So, this is already handled.