@realthunder - Thanks I upped your Patreon to allow for the bonus payment and then reset it back to the normal value. As Patreon does not allow one time payments.realthunder wrote: ↑Tue Mar 09, 2021 3:16 amYes, PR submitted now probably will just be pending till 0.20 starts. You can test it with my release first.keithsloan52 wrote: ↑Sun Mar 07, 2021 4:38 pm Look forward to testing. I guess given feature freeze it will be in 0.20 rather than 0.19, would have been good to have it make production 0.19.
Converting from a different rotation system.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
Trying to test this but does not appear to be in your latest buildrealthunder wrote: ↑Sun Mar 07, 2021 10:17 amI have just added this capability to FreeCAD.Rotation.keithsloan52 wrote: ↑Fri Feb 05, 2021 2:31 pm I am trying to deal with some software that specifies rotation as x=<value> y=<value> z=<value>, where the values are passes as either degrees or radians ( Different parameter). As it is possible for more than one axis to be specified the order is important and this system does x rotation, then y, then z. What is the best way to go from the three values x,y,z to a FreeCAD placement rotation? Do I have to go via three separate rotations?
Use FreeCAD.Rotation(seq, a, b, c) to create a rotation with rotation sequence 'seq', and angles a, b, c in degree. Use function Rotation.toEulerAngles(seq) to obtain the angles. Call this function without argument to obtain all possible sequence types. Intrinsic sequences is prefixed with 'i', while extrinsic ones has no prefix. Your pattern looks like an intrinsic rotation sequence with order xyz, so seq='ixyz'. I'll make a new release of my branch with the feature. I'll also submit a PR for this soon.
I borrow the code from OCCT gp_Quaternion::Get/SetEulerAngles().
The following Python code can be used for verification, e.g. checkRot('ixyz', 10, 20, 30)Code: Select all
def checkRot(seq, a, b, c): rot = FreeCAD.Rotation() if seq[0] == 'i': for axis,angle in zip(seq[1:], (a, b, c)): if axis == 'x': rot *= FreeCAD.Rotation(FreeCAD.Vector(1,0,0), angle) elif axis == 'y': rot *= FreeCAD.Rotation(FreeCAD.Vector(0,1,0), angle) else: rot *= FreeCAD.Rotation(FreeCAD.Vector(0,0,1), angle) else: for axis,angle in zip(seq, (a, b, c)): if axis == 'x': rot *= FreeCAD.Rotation(rot.inverted()*FreeCAD.Vector(1,0,0), angle) elif axis == 'y': rot *= FreeCAD.Rotation(rot.inverted()*FreeCAD.Vector(0,1,0), angle) else: rot *= FreeCAD.Rotation(rot.inverted()*FreeCAD.Vector(0,0,1), angle) print(rot.toEulerAngles(seq)) return FreeCAD.Rotation(seq, a, b, c).isSame(rot, 1e-12)
Code: Select all
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2021.328.24301 +3441 (Git)
Build type: Release
Branch: LinkStage3
Hash: 0a157a307c91d241a370cdda6d8f0471b7c48915
Python version: 3.7.10
Qt version: 5.12.1
Coin version: 4.0.1
OCC version: 7.4.0
Locale: C/Default (C)
Code: Select all
06:38:05 Traceback (most recent call last):
File "<string>", line 7, in <module>
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2261, in export
exportGDMLworld(first,filepath,fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2062, in exportGDMLworld
exportGDML(first,filepath,fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2010, in exportGDML
exportWorldVol(first, fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1957, in exportWorldVol
processVolume(vol, xmlVol, xmlParent, parentName, False)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1851, in processVolume
xmlVol, volName, xmlParent, parentName)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1559, in processObject
processVolAssem(obj, xmlVol, volName, True)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1867, in processVolAssem
processVolume(vol, newXmlVol, xmlParent, parentName, addVolsFlag)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1851, in processVolume
xmlVol, volName, xmlParent, parentName)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1593, in processObject
xmlParent, parentName)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1520, in processBooleanObject
boolCnt, boolxml, solidName = processSolid(obj, True)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1379, in processSolid
processRotation(obj.Tool,subtract)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 652, in processRotatio<class 'TypeError'>: function takes exactly 0 arguments (1 given)
You mention try in Assembler3, Is that just a case of installing the Assembler3 workbench?
Reason I have been slow to test is on import I get a load of messages that I don't get with FreeCAD i.e FreeCAD 0.19.1
Code: Select all
6:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 DeprecationWarning: Second argument is deprecated. It is ignored and will be removed in future versions. The default Python feature proxy is used for extension method overrides.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 Recompute failed! Please check report view.
06:34:17 End processing GDML file
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Converting from a different rotation system.
toEuler() is the old function. The function I added is called toEulerAngles(). The source code here that can be found at here. But as the changes are in the C++ code, I am afraid you get that easily with your workbench. Once you've tested it, I will submit it to upstream.keithsloan52 wrote: ↑Fri Apr 02, 2021 5:45 am I also notice that the error is not at 652, but the toEuler call is in the function processRotation and if I alter it to toEuler() from toEuler('ixyz') I don't get the error.
I mean try it using my branch.You mention try in Assembler3, Is that just a case of installing the Assembler3 workbench?
Do you mean you get the recompute failure when loading file using my branch? Can you please post some sample file here?Reason I have been slow to test is on import I get a load of messages that I don't get with FreeCAD i.e FreeCAD 0.19.1
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
toEuler('ixyz') was coded in branch link3 which I have only just pushed to the Github repro, it was what I was testing on locally.
On my system I get error
Not sure why it does not report the actual/correct function and line number, but when I change back to toEuler() the error goes away
and some things are not rotated correctly. I have a smaller file that also shows the export rotation issue but unfortunately not allowed to share as confidential.
The file is as per first item of issue 40 see https://github.com/KeithSloan/GDML/issues/40
rich_mirror12_457.gdml
On Pauly system it takes 3 or 5 mins to load/import on my system it is more like 15 mins with 11 mins CPU (666 secs)
He is using some flavour of Linux and looks okay, but export then reimport shows some items not rotated correctly.
Think I need to learn how to use an interactive debugger and get rid of all the trace calls or at least comment them out
might help a bit.
Export is very quick, so quick one thinks it cannot possibly have worked.
My system LinkStage 3 info
Thanks for your help
Keith
On my system I get error
Code: Select all
17:17:56 Export Rotation
17:17:56 Traceback (most recent call last):
File "<string>", line 7, in <module>
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2261, in export
exportGDMLworld(first,filepath,fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2062, in exportGDMLworld
exportGDML(first,filepath,fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 2010, in exportGDML
exportWorldVol(first, fileExt)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1960, in exportWorldVol
processAssembly(vol, xmlVol, xmlParent, parentName, False)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1798, in processAssembly
processVolAssem(obj, xmlVol, volName, addVolsFlag)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1867, in processVolAssem
processVolume(vol, newXmlVol, xmlParent, parentName, addVolsFlag)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1851, in processVolume
xmlVol, volName, xmlParent, parentName)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1559, in processObject
processVolAssem(obj, xmlVol, volName, True)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1867, in processVolAssem
processVolume(vol, newXmlVol, xmlParent, parentName, addVolsFlag)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1851, in processVolume
xmlVol, volName, xmlParent, parentName)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad/gdml/exportGDML.py", line 1559, in processObject
processVolAssem(obj, xmlVol, volName, True)
File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/GDML/freecad<class 'TypeError'>: function takes exactly 0 arguments (1 given)
and some things are not rotated correctly. I have a smaller file that also shows the export rotation issue but unfortunately not allowed to share as confidential.
The file is as per first item of issue 40 see https://github.com/KeithSloan/GDML/issues/40
rich_mirror12_457.gdml
On Pauly system it takes 3 or 5 mins to load/import on my system it is more like 15 mins with 11 mins CPU (666 secs)
He is using some flavour of Linux and looks okay, but export then reimport shows some items not rotated correctly.
Think I need to learn how to use an interactive debugger and get rid of all the trace calls or at least comment them out
might help a bit.
Export is very quick, so quick one thinks it cannot possibly have worked.
My system LinkStage 3 info
Code: Select all
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2021.328.24301 +3441 (Git)
Build type: Release
Branch: LinkStage3
Hash: 0a157a307c91d241a370cdda6d8f0471b7c48915
Python version: 3.7.10
Qt version: 5.12.1
Coin version: 4.0.1
OCC version: 7.4.0
Locale: C/Default (C)
Keith
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
Tried toEulerAngles('ixyz') Same result wants zero parameters
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Converting from a different rotation system.
I have submitted a PR to your GDML github repo. Make sure you test it with my release, preferable the latest Daily release. I was able to import the rich_mirror gdml file in just 6 seconds.keithsloan52 wrote: ↑Sun Apr 04, 2021 5:36 pm Tried toEulerAngles('ixyz') Same result wants zero parameters
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
Great news Zheng - Look forward to testing. Who knows we might even get to the state where importing Alice.gdml and other CERN experiments is practical.realthunder wrote: ↑Mon Apr 12, 2021 6:34 amI have submitted a PR to your GDML github repo. Make sure you test it with my release, preferable the latest Daily release. I was able to import the rich_mirror gdml file in just 6 seconds.keithsloan52 wrote: ↑Sun Apr 04, 2021 5:36 pm Tried toEulerAngles('ixyz') Same result wants zero parameters
By the way is Zheng first or second name, I have a vague impression that some Asian Societies use family name first, but could be wrong?
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Converting from a different rotation system.
Yes, that's my family name, and we do put it firstkeithsloan52 wrote: ↑Mon Apr 12, 2021 8:53 am By the way is Zheng first or second name, I have a vague impression that some Asian Societies use family name first, but could be wrong?
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Converting from a different rotation system.
Thanks Lei Good to Knowrealthunder wrote: ↑Mon Apr 12, 2021 9:22 amYes, that's my family name, and we do put it firstkeithsloan52 wrote: ↑Mon Apr 12, 2021 8:53 am By the way is Zheng first or second name, I have a vague impression that some Asian Societies use family name first, but could be wrong?
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am