Error at the position because of the Rotation centre ?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Error at the position because of the Rotation centre ?

Post by manos »

Code: Select all

OS: Ubuntu 18.04.5 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: English/United States (en_US)
Installed mods: 
  * workfeature-macro
  * Manipulator 1.4.9
  * Help 1.0.3
  * workfeature
I have written this snippet at which I set the Placement.base. vector at 10,20,4 position and the centre at v(0,0,0) . As expected the placement position was at 10,20,4 . Then I changed the centre at 30,30,30 and at my big surprise the new placement position was at 10.52, 19.48, 4 .
It is about 5% error. Any explanation ?
Attachments
Box1.FCStd
(8.89 KiB) Downloaded 12 times
centre_issue.py
(416 Bytes) Downloaded 12 times
Last edited by manos on Tue Sep 27, 2022 4:23 am, edited 1 time in total.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Error at the [position because of the Rotation centre ?

Post by openBrain »

Your code says : apply rotation of 1° around Z axis with rotation center at (30,30,30) then place object at (10,20,4).
Anyway, I didn't check the calculation but the result seems correct to me.
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: Error at the [position because of the Rotation centre ?

Post by manos »

openBrain wrote: Mon Sep 26, 2022 11:41 am Your code says : apply rotation of 1° around Z axis with rotation center at (30,30,30) then place object at (10,20,4).
Anyway, I didn't check the calculation but the result seems correct to me.

The correct result is : " Global Placement after recomp= Placement [Pos=(10.0,20.0,4), Yaw-Pitch-Roll=(1,0,0)]. "
But I had this one : " Global Placement after recomp= Placement [Pos=(10.5281, 19.481, 4), Yaw-Pitch-Roll=(1,0,0)] "
Which one did you have ?
Thanks for help
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Error at the [position because of the Rotation centre ?

Post by openBrain »

manos wrote: Mon Sep 26, 2022 12:25 pm The correct result is : " Global Placement after recomp= Placement [Pos=(10.0,20.0,4), Yaw-Pitch-Roll=(1,0,0)]. "
No it's not because you offset the rotation center.
If you want this :

Code: Select all

newplace=FreeCAD.Placement(pos,rot) # remove "centre"
The question is : why are you offsetting the rotation center ?
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: Error at the [position because of the Rotation centre ?

Post by manos »

openBrain wrote: Mon Sep 26, 2022 12:28 pm The correct result is : " Global Placement after recomp= Placement [Pos=(10.0,20.0,4), Yaw-Pitch-Roll=(1,0,0)]. "
No it's not because you offset the rotation center.
No to No: The deviation is not directly proportional to the offset . And the rotation center what has to do with the position of the prism which is symmetrical ? Maybe it is a bug.

The question is : why are you offsetting the rotation center ?
I try to use an edge of the prism as axis of rotation.

Thanks anyway openBrain.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Error at the [position because of the Rotation centre ?

Post by openBrain »

manos wrote: Mon Sep 26, 2022 12:52 pm No to No: The deviation is not directly proportional to the offset .
Sure. This is rotations, so basically trigonometrical things. And trigonometric functions aren't linear.
And the rotation center what has to do with the position of the prism which is symmetrical ? Maybe it is a bug.
I don't know how to better explain. Take your file (from the OP) and check this (this is same rotation as you do, but without translating the base)

Code: Select all

>>> App.ActiveDocument.Body.Placement = App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1),1), App.Vector(30,30,30))
>>> App.ActiveDocument.Body.Placement
Placement [Pos=(0.528141,-0.519003,0), Yaw-Pitch-Roll=(1,0,0)]
And bing. You see the offset that the rotation creates on the base. It perfectly matches what you see.

Maybe you should tell what you are (functionally) trying to achieve.
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: Error at the position because of the Rotation centre ?

Post by manos »

openBrain wrote: Mon Sep 26, 2022 2:07 pm
Thanks open Brain I will try all that. By the way what does it mean "Take your file (from the OP) " ?
Last edited by manos on Tue Sep 27, 2022 4:23 am, edited 1 time in total.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Error at the [position because of the Rotation centre ?

Post by openBrain »

It means I did it using the file you posted in the OP.
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: Error at the [position because of the Rotation centre ?

Post by manos »

openBrain wrote: Tue Sep 27, 2022 3:34 am It means I did it using the file you posted in the OP.
Yes but what is the OP anyway ?
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Error at the position because of the Rotation centre ?

Post by freedman »

OP = Original post = first post = starting post

manos, about placements: keep track of the wording attachment offset and placement and how the placement is changed. We don't want to guess how a placement got modified.
Thanks
Post Reply