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
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
Getting euler angles
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 1
- Joined: Tue Aug 16, 2022 6:01 am
- thomas-neemann
- Veteran
- Posts: 11958
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: Getting euler angles
deleted because wrong
Last edited by thomas-neemann on Tue Aug 16, 2022 12:45 pm, edited 4 times in total.
- papyblaise
- Veteran
- Posts: 8026
- Joined: Thu Jun 13, 2019 4:28 pm
- Location: France
Re: Getting euler angles
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 (82.95 KiB) Viewed 530 times
Re: Getting euler angles
To my knowledge, only obtainable from Python. Try (on the Python console's command line):amirsteinitz wrote: ↑Tue Aug 16, 2022 6:20 am >>> # Gui.Selection.clearSelection()
>>> # Gui.Selection.addSelection('Unnamed','Compound','Face1203',2576.49,-389.134,1138.75)
>>>
Code: Select all
print(App.ActiveDocument.Compound.Shape.Faces[1202].normalAt(0, 0))
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)))
Cheers,
Markus
Markus
- thomas-neemann
- Veteran
- Posts: 11958
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: Getting euler angles
is that helpful?
-
- Veteran
- Posts: 3192
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Getting euler angles
Not the same: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°
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)