Hi everyone !
I've been blaying with the python API, and especiallly the "Placement" object.
I might have found a bug :
In a console :
>>> p = FreeCAD.Placement()
>>> p.Rotation.Angle = 1.57
>>> p.inverse().Rotation.Angle
0.0
That should not be that, ins't it ? I should get -1.57, right ?
Thanks !
OS: Debian GNU/Linux 11 (bullseye) (XFCE/xfce)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.9.2
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)
[Fixed] Bug on inverted Placement
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[Fixed] Bug on inverted Placement
Last edited by dpoen on Mon Jun 20, 2022 9:03 am, edited 1 time in total.
Re: Bug on inverted Placement
Hello,
What you do have basically no sense. A rotation is defined by not only an angle, but also an axis.
If we don't have the axis (especially for first, but let's say for both), it's just 2 numbers.
What you do have basically no sense. A rotation is defined by not only an angle, but also an axis.
If we don't have the axis (especially for first, but let's say for both), it's just 2 numbers.
Re: Bug on inverted Placement
Yes, and the axis is by default (0,0,1), so the inverted rotation should either be the same angle (1.57) but with the opposite axis (0,0,-1), or use the same axis (0,0,1) but using the opposite angle (-1.57)
Both way, the rotation angle should not be 0, imo
EDIT : I just look up, and it actually choose to invert the axis, so as a follow-up to my example in my first post, if I do :
>>> p.inverse().Rotation.Axis
(0,0,-1)
That should force to display p.inverse().Rotation.Angle = 1.57
I don't agree (or I don't understand you) about "not making sense", and if it actually not make sense, I think the "inverse()" method should be removed from the Placement object.
And additionnaly, this command seems to otherwise work, considering that :
>>> p.inverse().Rotation.Matrix - p.Rotation.Matrix.inverse()
give the zero matrix
Hope I've got your point, and made mine clearer
Both way, the rotation angle should not be 0, imo
EDIT : I just look up, and it actually choose to invert the axis, so as a follow-up to my example in my first post, if I do :
>>> p.inverse().Rotation.Axis
(0,0,-1)
That should force to display p.inverse().Rotation.Angle = 1.57
I don't agree (or I don't understand you) about "not making sense", and if it actually not make sense, I think the "inverse()" method should be removed from the Placement object.
And additionnaly, this command seems to otherwise work, considering that :
>>> p.inverse().Rotation.Matrix - p.Rotation.Matrix.inverse()
give the zero matrix
Hope I've got your point, and made mine clearer
-
- Posts: 124
- Joined: Wed Jun 19, 2019 7:44 pm
Re: Bug on inverted Placement
there is a bug in Rotation::inverse(). Only the array representing the quaternion and the Vector3D axis are changed, but not the _angle member.
-
- Posts: 124
- Joined: Wed Jun 19, 2019 7:44 pm
Re: Bug on inverted Placement
Thanks you sir !
Re: [Fixed] Bug on inverted Placement
Probably this forum discussion will make some light on the matter, that is not trivial and not unique:
Angles discussion about the 24 types of Cardan angles and similar
https://forum.freecadweb.org/viewtopic. ... 5&start=20
You will see also some hints on the math behind the things, in the comment present in the source:
https://github.com/FreeCAD/FreeCAD/blob ... tation.cpp
Hope it helps.
Carlo D.
Angles discussion about the 24 types of Cardan angles and similar
https://forum.freecadweb.org/viewtopic. ... 5&start=20
You will see also some hints on the math behind the things, in the comment present in the source:
https://github.com/FreeCAD/FreeCAD/blob ... tation.cpp
Hope it helps.
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Bug on inverted Placement
It seems that has been integrated in new builds.
https://github.com/FreeCAD/FreeCAD/comm ... 989800b334
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/