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 ?
Error at the position because of the Rotation centre ?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Error at the position because of the Rotation centre ?
Re: Error at the position because of the Rotation centre ?
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Error at the position because of the Rotation centre ?
I have never used Attachment or Link. Only placement constructors with Position, Rotation, Centre.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.
At this time I am trying to learn how to use the Placement method.what you are trying to achieve?
Regards
Carlo D.
Thanks for help.
Re: Error at the position because of the Rotation centre ?
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:
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.
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)
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.
Re: Error at the position because of the 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.
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)
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Error at the position because of the Rotation centre ?
"At this time I am trying to learn how to use the Placement method in scripts" I must had written.
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.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 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.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)
Regards
Carlo D.
@vmayer thank you so much for the extended answer. I will read it carefully.