View Issue Details

IDProjectCategoryView StatusLast Update
0003200FreeCADBugpublic2017-10-07 09:44
Reporterplgarcia Assigned Toeivindkvedalen  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.17 
Fixed in Version0.17 
Summary0003200: Error with angles in formulas
DescriptionThere are problems using angles in formulas.
The value of the angle used in the formula is in radians but considered as degrees.


I understand that is or may become a problem, as the value that should be used in trigonometric finctions should be radians and the representation is in degrees. Here there is a confusion of the internal representation and the presentation in the GUI.

For me it is a bug.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12223 (Git)
Build type: Release
Branch: master
Hash: 917e61a3be12f3316d571ebf6fd6e3c537691c14
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: French/France (fr_FR)
Steps To ReproduceMy example 2 cube.
I set the angle of the first cube to 45° and shown in picture1.
Then I set the angle of the second cube with a formua as being equals to the angle of the first cube as shown in pcture2.
The value takent by this angle is 0.79 as shown in picture3.
0.79 is the value in radians of à 45°angle, but it is considered as being in degrees what is wrong, what shows the position of the 2 cubes on the view.

Here are the logs seen in Python console.
>>> FreeCAD.getDocument("Sans_nom").getObject("Box").Placement = App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),45))
>>> FreeCAD.getDocument("Sans_nom").getObject("Box001").Placement = App.Placement(App.Vector(12.8799,10.1293,6.24988),App.Rotation(App.Vector(0,0,1),0.79))
>>> App.getDocument('Sans_nom').Box001.setExpression('Placement.Rotation.Angle', u'Cube.Placement.Rotation.Angle')
>>> FreeCAD.getDocument("Sans_nom").getObject("Box001").Placement = App.Placement(App.Vector(12.8799,10.1293,6.24988),App.Rotation(App.Vector(0,0,1),0.79))
>>>
Also shown in picture4.

Additional InformationForum topic
https://forum.freecadweb.org/viewtopic.php?f=10&t=24662
Tagsexpressions, spreadsheet
FreeCAD Information

Activities

plgarcia

2017-09-28 15:27

reporter  

picture3.png (21,034 bytes)   
picture3.png (21,034 bytes)   
picture4.png (25,381 bytes)   
picture4.png (25,381 bytes)   
picture1.png (19,879 bytes)   
picture1.png (19,879 bytes)   
picture2.png (22,444 bytes)   
picture2.png (22,444 bytes)   

Kunda1

2017-09-28 17:31

administrator   ~0010208

@eivindkvedalen do you mind weighing in?

plgarcia

2017-09-29 09:36

reporter   ~0010211

sin(cube.Placement.Rotation.Angle) gives also a wrong result
sin(cube.Placement.Rotation.Angle*180/3.141593) gives the result expected (0,71 if cube angle is set to 45°)

plgarcia

2017-09-29 11:31

reporter   ~0010212

Kunda1 I do not understand the question.

I mean that in the formula I set the angle of cube001 as being equal to the angle of Cube. So I would have expected the angle of Cube001 to be set to 45° or 0.79 rad but not to 0.79°

Kunda1

2017-10-02 13:23

administrator   ~0010237

@plgarcia i was pinging a user to offer some feedback. In this case it is eivindkvedalen whom authored 'expressions'.

plgarcia

2017-10-04 18:46

reporter   ~0010243

Last edited: 2017-10-04 18:51

eivindkvedalen

Your change works!
45° is 45° and sin(45°) is 0,71!

I tested it on Linux Ubuntu 17.04

Thank you
Regards
Pascal Garcia

Kunda1

2017-10-05 04:11

administrator   ~0010245

FreeCAD Pull Request 1016

wmayer

2017-10-07 09:44

administrator   ~0010259

https://github.com/FreeCAD/FreeCAD/commit/1cf3667f628148ed8461008a80ab505a24b0d0dd

Issue History

Date Modified Username Field Change
2017-09-28 15:27 plgarcia New Issue
2017-09-28 15:27 plgarcia File Added: picture3.png
2017-09-28 15:27 plgarcia File Added: picture4.png
2017-09-28 15:27 plgarcia File Added: picture1.png
2017-09-28 15:27 plgarcia File Added: picture2.png
2017-09-28 17:30 Kunda1 Tag Attached: expressions
2017-09-28 17:30 Kunda1 Tag Attached: spreadsheet
2017-09-28 17:31 Kunda1 Note Added: 0010208
2017-09-29 09:36 plgarcia Note Added: 0010211
2017-09-29 11:31 plgarcia Note Added: 0010212
2017-10-02 13:23 Kunda1 Note Added: 0010237
2017-10-03 07:45 eivindkvedalen Assigned To => eivindkvedalen
2017-10-03 07:45 eivindkvedalen Status new => assigned
2017-10-04 18:46 plgarcia Note Added: 0010243
2017-10-04 18:50 plgarcia Note Edited: 0010243
2017-10-04 18:51 plgarcia Note Edited: 0010243
2017-10-05 04:11 Kunda1 Note Added: 0010245
2017-10-07 09:44 wmayer Status assigned => closed
2017-10-07 09:44 wmayer Resolution open => fixed
2017-10-07 09:44 wmayer Fixed in Version => 0.17
2017-10-07 09:44 wmayer Note Added: 0010259