Default angle units: radian? degree?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
ezzieyguywuf
Posts: 656
Joined: Tue May 19, 2015 1:11 am

Default angle units: radian? degree?

Post by ezzieyguywuf »

I am attempting to work through a backlog of Spreadsheet module bugs, and have come across bug report 3255. Rather than revive this old help thread on the topic, I thought it would be more prudent to start a new thread in the Open Discussion forum.

Continuing from the discussion in the linked help thread: Despite the fact that "fx" and "value" use different parsers, I think it is critical that the user experiences consistent behaviour.

Further, the convention with calculators seems to be to allow the user to set a global angle default (Deg or Rad) to be used in these trigonometric functions. These globals can be overridden on certain calculators by specifying the unit in the calculation.

You can see some of what I'm talking about in this video, though in the video he prefers to set the calculator mode versus over-writing the default.

This page in te TI36x user manual describes how the user can input an angle unit to over-ride the default value.

Therefore, I propose that within the FreeCAD preferences we allow the user to specify an angle "mode" (i.e. degrees or radians) which will be used in all trigonometric functions.

For expressions that understand units, the user can over-ride this default unit type. for expressions that don't understand units, the user can expect the default unit-type to be used.

If there is some general consensus that this behaviour is reasonable, I can prepare a PR to implement this feature.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Default angle units: radian? degree?

Post by openBrain »

Hmm. Actually I think FC is primarily a CAD software and should stay one. And IMO no one expect anything but seeing the angle values in degrees (eg. in Sketcher). This I'd go for something simpler : default unit for angles is degree unless user specifically enter another unit. ;)
ezzieyguywuf
Posts: 656
Joined: Tue May 19, 2015 1:11 am

Re: Default angle units: radian? degree?

Post by ezzieyguywuf »

openBrain wrote: Tue Dec 03, 2019 7:49 am Hmm. Actually I think FC is primarily a CAD software and should stay one.
Yes I agree with this.
openBrain wrote: Tue Dec 03, 2019 7:49 am And IMO no one expect anything but seeing the angle values in degrees (eg. in Sketcher).
I don't understand what you mean here - you're saying that user's do not expect a consistent interface? How can that be? It should be one of the fundamental tenets of sound programming design that a piece of software behave in a predictable and sane manner.
openBrain wrote: Tue Dec 03, 2019 7:49 am This I'd go for something simpler : default unit for angles is degree unless user specifically enter another unit.
This is mostly what I am advocating for - to start with a default that it used everywhere, unless the user specifies a specific unit.

However, I believe that:
  1. The default should be radians
  2. The user should be able to change the default
Why should the default be radians? Because that's how math works. Radian is a dimensionless unit, therefore if I see an expression "sin(30)" I immediately assume this is in radians due to lack of evidence otherwise.

Why should the user be able to change the default? Because there are large populations of users (such as yourself, I gather) who prefer for the default to be degrees and have no issues with looking at "sin(30)" and assuming it is degrees.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Default angle units: radian? degree?

Post by openBrain »

ezzieyguywuf wrote: Tue Dec 03, 2019 5:56 pm
openBrain wrote: Tue Dec 03, 2019 7:49 am And IMO no one expect anything but seeing the angle values in degrees (eg. in Sketcher).
I don't understand what you mean here - you're saying that user's do not expect a consistent interface? How can that be? It should be one of the fundamental tenets of sound programming design that a piece of software behave in a predictable and sane manner.
I just say that (AFAIK), CAD always uses degrees. ;) So when you use a CAD software, you just expect the angle to be ... degrees. :)
Why should the default be radians? Because that's how math works. Radian is a dimensionless unit, therefore if I see an expression "sin(30)" I immediately assume this is in radians due to lack of evidence otherwise.
For above reason, I don't really agree. If I use Scilab, I expect angles to be in radians. If I use FreeCAD, I expect angles to be in degrees. ;)
Why should the user be able to change the default? Because there are large populations of users (such as yourself, I gather) who prefer for the default to be degrees and have no issues with looking at "sin(30)" and assuming it is degrees.
As said, I'm flexible depending on what I'm doing. ;)
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: Default angle units: radian? degree?

Post by adrianinsaval »

ezzieyguywuf wrote: Tue Dec 03, 2019 5:56 pm Why should the default be radians? Because that's how math works. Radian is a dimensionless unit, therefore if I see an expression "sin(30)" I immediately assume this is in radians due to lack of evidence otherwise.
Agreed.
ezzieyguywuf wrote: Tue Dec 03, 2019 5:56 pm Why should the user be able to change the default? Because there are large populations of users (such as yourself, I gather) who prefer for the default to be degrees and have no issues with looking at "sin(30)" and assuming it is degrees.
What would happen if I make my model with radians as default and then send it to someone with degrees as default? Will FreeCAD add the apropiate unit internally so the model won't break?
ezzieyguywuf
Posts: 656
Joined: Tue May 19, 2015 1:11 am

Re: Default angle units: radian? degree?

Post by ezzieyguywuf »

adrianinsaval wrote: Tue Dec 03, 2019 7:14 pm What would happen if I make my model with radians as default and then send it to someone with degrees as default? Will FreeCAD add the apropiate unit internally so the model won't break?
Great question!

There are many ways that this could be addressed - off the top of my head, I would say we could do something as follows: essentially, the user-defined default angle unit would only matter at the time that a given user is inputting a new value. In the background, FreeCAD always saves in the same unit type (radians! :-P).

However, what is different is what the user sees: based on their preferences, they either see this saved value as a radian or a degree.

In fact, this is completely in-line with how FreeCAD manages units in general.

For example, if I have my units set to metric, I can still make a square of length "10 in". However, FreeCAD will convert this to "254 mm", and that is what is displayed in the property dock.

If I create a square of length "10", FreeCAD will default to the user-defined metric system and create the square with length of "10 mm".

This is the same behaviour I think we should expect with angles.
User avatar
adrianinsaval
Veteran
Posts: 5553
Joined: Thu Apr 05, 2018 5:15 pm

Re: Default angle units: radian? degree?

Post by adrianinsaval »

Then I guess it should be controlled by the Unit System preference that's already there
ezzieyguywuf
Posts: 656
Joined: Tue May 19, 2015 1:11 am

Re: Default angle units: radian? degree?

Post by ezzieyguywuf »

adrianinsaval wrote: Tue Dec 03, 2019 9:11 pm Then I guess it should be controlled by the Unit System preference that's already there
Yes this is likely the most sensible solution.

In fact, probably the main change that needs to be made is to ensure that the ExpressionParser respects these preferences.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Default angle units: radian? degree?

Post by ulrich1a »

One of the main points of the bug was, that the math of the input fields was not documented. So doing the documentation would halfway fix the bug report without any programmatic change to FreeCAD.
ezzieyguywuf wrote: Tue Dec 03, 2019 4:00 am If there is some general consensus that this behaviour is reasonable, I can prepare a PR to implement this feature.
I do not think, that there is an easy way to implement this with a benefit for the user. The following things have to be considered:
  • CAD-drawings have a long tradition of using degrees for angular dimension. I would expect, that this is standardized somewhere, but could not find one actually. An example for using degrees in drawings is that most available protractors are scaled with degrees. So a fix should include, that the angles in drawings are always given in degrees.
  • There is a nasty behavior in a lot of dimensional input dialogs. You can not put in numbers with 15 valid figures. This has consequences for using pi in such dialog boxes. Here is an example you can try yourself: Set your preferences to 2 numbers in the menu edit/preferences/general/untis. Create a box feature in Part Design and set one length to "pi mm" in the dialog that appears in the taskbar. Have a look into the python console, in order to see your input. You have set the length to exactly 3.14000 mm. Consider to set an angle of 90° in such a input field by putting in pi/2. You will never get a usable design with FreeCAD. I would expect that you have to write a lot of documentation or fix all this before you get any advantage for the average user.
  • There is already a user base of FreeCAD with a pile of documents sitting somewhere. So old documents should be still valid after a recalculation. A PR should consider this and handle settings in an old document. There may be a need to save the actual setting in a document, in order to interpret some values correctly.
I say this, because I want something that makes FreeCAD better. There are a lot of things to consider, before a good solution is at hands.

Ulrich
Post Reply