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

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

Post by manos »

freedman wrote: Tue Sep 27, 2022 6:00 am .......
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
Good morning freedman. Thanks for your message but frankly even though I know all the words of this sentence, I don't understand the whole meaning. Could you rephrase it please ?
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

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

Post by onekk »

manos wrote: Tue Sep 27, 2022 6:18 am ...
It depends, on what you are using, as example if you make a "Part Design" and use some Attachment or Link, you have the "original object" placement and the "attachment offset", so the shown position is the "sum" or better the "combination" of the two things.

In this case, it depends on what you are using to retrieve the position, if you use the "position of the original object" and there is a different attachment offset you are simply using the wrong data.

Sadly FC is quite flexible and the different ways of doing things are a consequence of his "flexibility" that lead to his "perceived complexity".

Recently you are doing many questions, but the problem could simply be as many helpers have asked you:

what you are trying to achieve?


Regards

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/
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 »

onekk wrote: Tue Sep 27, 2022 7:49 am ...
It depends, on what you are using, as example if you make a "Part Design" and use some Attachment or Link, you have the "original object" placement and the "attachment offset", so the shown position is the "sum" or better the "combination" of the two things.
I have never used Attachment or Link. Only placement constructors with Position, Rotation, Centre.
what you are trying to achieve?
Regards

Carlo D.
At this time I am trying to learn how to use the Placement method.
Thanks for help.
wmayer
Founder
Posts: 20301
Joined: Thu Feb 19, 2009 10:32 am
Contact:

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

Post by wmayer »

If you rotate around a center point then what happens is that it first applies the negative translation to the center, performs the rotation and then applies again the positive translation to the center point.

In a more formal way:
In FreeCAD a placement is a rotation and a translation and the affine transformation can be expressed as:

y = R * x + t where R is the rotation matrix, t the translation and x an arbitrary point. y is the transformed point.

If you rotate around the point c then the expression becomes:

y = R * (x - c) + c + t
<=>
y = R * x - R * c + c + t

This means the new translation of the placement will be:
c - R * c + t

Now we have:
c = (30, 30, 30)
t = (10, 20, 4)
R a rotation around the Z axis by 1 degree

In Python:

Code: Select all

import math
from FreeCAD import Base
v = Base.Vector

c = v(30, 30, 30)
t = v(10, 20, 4)
R = Base.Matrix()
R.rotateZ(math.radians(1))
c - R.multVec(c) + t

# Vector (10.528141338426767, 19.48099695218976, 4.0)
You expected that setting an arbitrary rotation center doesn't affect the translation but this is wrong. If you consider this equation
t = c - R * c + t
<=>
0 = c - R * c
<=>
R * c = c
then you can easily see that this is only true if R is the identity matrix or c the origin. Now if R is the identity matrix then you actually don't perform a rotation and if c is the origin you don't rotate around an arbitrary point.
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

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

Post by onekk »

manos wrote: Tue Sep 27, 2022 8:31 am I have never used Attachment or Link. Only placement constructors with Position, Rotation, Centre.
It was only an answer to the explanation of attachment and link, cited by @freedman in the post you linked, (and that is refenced by the litle cross near the manos in the quoted message, Probably this time is my fault, as I'm used to refer to message if not essential without quoting the whole message.
manos wrote: Tue Sep 27, 2022 8:31 am At this time I am trying to learn how to use the Placement method.
Thanks for help.
This page is not helping:

https://wiki.freecadweb.org/Placement


(Feel free to suggest what is not clear, this is a "good habit" as it is a "constructive critic")

As a side note, take in account that if you do some heavy math you have to take in account rounding errors.

Plus using Matrix could be easy and intuitive, but Placement is stored as a quaternion, so every passage between an "Object Placement" and a matrix to make calculations will be subject to these errors, maybe doubled as you pass from Matrix to Placement after having operated on the matrix.

Some imprecision should be taken in account.

I'm not so skilled in math to suggest workarounds, but probably using the supplied tranfsormations should do the work.

But @wmayer has done a exaustive answer, sadly I'm "math impaired" so I can guess about 50% of the thing he has said. (Probably as my son as started high school, I will steal some of his math books and study them) :D

Regards

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/
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 »

onekk wrote: Tue Sep 27, 2022 10:26 am
At this time I am trying to learn how to use the Placement method.
"At this time I am trying to learn how to use the Placement method in scripts" I must had written.
This page is not helping:

https://wiki.freecadweb.org/Placement

(Feel free to suggest what is not clear, this is a "good habit" as it is a "constructive critic")
Indeed as it concerns- this written crime - the pages : "https://wiki.freecadweb.org/Placement" the first thing I have to suggest, is to add as much LCS @ GCS (Local and Global Coord. System) characterisations as needed. Mainly in Axis and Position Vectors.
But @wmayer has done a exaustive answer, sadly I'm "math impaired" so I can guess about 50% of the thing he has said. (Probably as my son as started high school, I will steal some of his math books and study them) :D

Regards

Carlo D.
As it concerns our children, my daughter who has started the second year in high school -I do not think her math books will help. I have spent some weeks studying Analytic Geometry , Vector Analysis and Linear Algebra for all that. Maybe these stuff will be found in secondary's education last year, or Universities first year. Anyway I will do it. Thanks for your help Carlo.

@vmayer thank you so much for the extended answer. I will read it carefully.
Post Reply