Getting euler angles

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
amirsteinitz
Posts: 1
Joined: Tue Aug 16, 2022 6:01 am

Getting euler angles

Post by amirsteinitz »

hi,
I am using FreeCAD v0.20 on Windows.
I have a question which should be quite easy to answer but I cannot find the answer.

I have a CAD file and I want to get the Euler angles for a surface vs. the coordinate system
Screenshot 2022-08-16 091727.png
Screenshot 2022-08-16 091727.png (126.73 KiB) Viewed 555 times
when I select (touch) the object this is what I see in the command line:

Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> # Gui.Selection.clearSelection()
>>> # Gui.Selection.addSelection('Unnamed','Compound','Face1203',2576.49,-389.134,1138.75)
>>>


I searched and looked around and cannot figure how to get the angles for the object.

Thanks
User avatar
thomas-neemann
Veteran
Posts: 11895
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Getting euler angles

Post by thomas-neemann »

deleted because wrong
Last edited by thomas-neemann on Tue Aug 16, 2022 12:45 pm, edited 4 times in total.
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
papyblaise
Veteran
Posts: 7998
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: Getting euler angles

Post by papyblaise »

I also don't understand why it displays 0.58, 0.58, 0.58 angle 120° when it is parallel to the ZY plane, it should be 0, 1.00, 0 angle 90°
Attachments
Euler.JPG
Euler.JPG (82.95 KiB) Viewed 502 times
User avatar
mfro
Posts: 666
Joined: Sat Sep 23, 2017 8:15 am

Re: Getting euler angles

Post by mfro »

amirsteinitz wrote: Tue Aug 16, 2022 6:20 am >>> # Gui.Selection.clearSelection()
>>> # Gui.Selection.addSelection('Unnamed','Compound','Face1203',2576.49,-389.134,1138.75)
>>>
To my knowledge, only obtainable from Python. Try (on the Python console's command line):

Code: Select all

print(App.ActiveDocument.Compound.Shape.Faces[1202].normalAt(0, 0))
(note that the name and the array index are off by one, i.e. naming is 1-based while index is 0-based)

This will print the normal vector of the face at (u=0, v=0). If you want the angles to the global coordinate system, you can get it using

Code: Select all

v = pp.ActiveDocument.Compound.Shape.Faces[1202].normalAt(0, 0)
print('toX=', v.getAngle(App.Vector(1, 0, 0)), 'toY=', v.getAngle(App.Vector(0, 1, 0)), 'toZ=', v.getAngle(App.Vector(0, 0, 1)))
(in radians)
Cheers,
Markus
User avatar
thomas-neemann
Veteran
Posts: 11895
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Getting euler angles

Post by thomas-neemann »

amirsteinitz wrote: Tue Aug 16, 2022 6:20 am ...
is that helpful?
Bildschirmfoto_2022-08-16_14-36-45.png
Bildschirmfoto_2022-08-16_14-36-45.png (123.17 KiB) Viewed 435 times
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
edwilliams16
Veteran
Posts: 3179
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Getting euler angles

Post by edwilliams16 »

papyblaise wrote: Tue Aug 16, 2022 8:59 am I also don't understand why it displays 0.58, 0.58, 0.58 angle 120° when it is parallel to the ZY plane, it should be 0, 1.00, 0 angle 90°
Not the same:

Code: Select all

>>> rot1 = App.Rotation(App.Vector(1,1,1), 120)
>>> rot2 = App.Rotation(App.Vector(0,1,0), 90)
>>> XAXIS = App.Vector(1, 0, 0)
>>> YAXIS = App.Vector(0, 1, 0)
>>> ZAXIS = App.Vector(0, 0, 1)
>>> 
>>> rot1 * XAXIS
Vector (1.1102230246251565e-16, 1.0, -1.1102230246251565e-16)
>>> rot2 * XAXIS
Vector (2.220446049250313e-16, 0.0, -1.0)
>>> rot1 * YAXIS
Vector (-1.1102230246251565e-16, 1.1102230246251565e-16, 1.0)
>>> rot2 * YAXIS
Vector (0.0, 1.0, 0.0)
>>> rot1 * ZAXIS
Vector (1.0, -1.1102230246251565e-16, 1.1102230246251565e-16)
>>> rot2 * ZAXIS
Vector (1.0, 0.0, 2.220446049250313e-16)
rot1 maps the XY plane to the YZ plane. rot2 maps it to -ZY. Same plane but rotated 90 degrees about its normal.
Post Reply