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!
Post Reply
UR_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Sketcher Arc Of Hyperbola Broken?

Post by UR_ »

Screenshot 001.png
Screenshot 001.png (34.56 KiB) Viewed 801 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
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Sketcher Arc Of Hyperbola Broken?

Post by bejant »

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
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Sketcher Arc Of Hyperbola Broken?

Post by hammax »

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

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

Re: Sketcher Arc Of Hyperbola Broken?

Post by pl7i92LCNC »

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

Re: Sketcher Arc Of Hyperbola Broken?

Post by wmayer »

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_
Veteran
Posts: 1354
Joined: Tue Jan 03, 2017 8:42 pm

Re: Sketcher Arc Of Hyperbola Broken?

Post by UR_ »

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
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher Arc Of Hyperbola Broken?

Post by wmayer »

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