[SOLVED] What is placement "root" and "inverse" terms ?

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

[SOLVED] What is placement "root" and "inverse" terms ?

Post by manos »

manos wrote: Wed Sep 21, 2022 7:14 pm
openBrain wrote: Mon Nov 29, 2021 5:15 pm ......To me your request makes sense, as I understand it as "set object placement so it maps to a vertex, both potentially being in different CS".
This is just a few calculus. Lets consider :
* obj : the object to move
* sk : the object owning the target vertex (called 'sk' because you said its a sketch, but can virtually be anything)
* id : the id of the target vertex in 'sk' shape ('id' is basically 'name-1', for example "Vertex3" has id = 2)
As you're targeting a vertex, there's no way to define a particular rotation for the object so I'll leave it unchanged

Code: Select all

skOffset = sk.getGlobalPlacement().multiply(sk.Placement.inverse()) # get sk root in GCS
targetPos = skOffset.multVec(sk.Shape.Vertexes[id].Point) # get target point coordinates in GCS
objOffset = obj.getGlobalPlacement().multiply(obj.Placement.inverse()) # get obj root in GCS
obj.Placement.Base = objOffset.inverse().multVec(targetPos) # move obj origin to sk.id
Hello
There is a term "root" in the line :" skOffset = sk.getGlobalPlacement().multiply(sk.Placement.inverse()) # get sk root in GCS".
There is a same - root- at: https://forum.freecadweb.org/viewtopic.php?f=22&t=64608 but its meaning is not clear to me so please explain.

At the above code snippet there is the attribute inverse.
Also at the @edwilliams16 Sandbox there is the command :pli = box.Placement.inverse()
Also delta_part001 = container_global_placement.inverse() * delta_global * container_global_placement

What is the purpose of " Placement.inverse" command ?

Thanks in advance.
Last edited by manos on Thu Sep 22, 2022 11:57 am, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: What is placement "root" and "inverse" terms ?

Post by onekk »

Code: Select all

help(FreeCAD.Placement.inverse)
Help on method_descriptor:

inverse(...)
    inverse() -> Base.Placement
    
    Compute the inverse placement.

Code: Select all

help(obj.getGlobalPlacement)
Help on built-in function getGlobalPlacement:

getGlobalPlacement(...) method of builtins.PrimitivePy instance
    getGlobalPlacement() -> Base.Placement
    
    Returns the placement of the object in the global coordinate space, respecting all stacked
    relationships.
    Note: This function is not available during recompute, as there the placements of parents
    can change after the execution of this object, rendering the result wrong.
https://forum.freecadweb.org/viewtopic. ... a5#p225497


https://forum.freecadweb.org/viewtopic. ... 83#p569083

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/
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: What is placement "root" and "inverse" terms ?

Post by openBrain »

manos wrote: Thu Sep 22, 2022 5:36 am There is a term "root" in the line :" skOffset = sk.getGlobalPlacement().multiply(sk.Placement.inverse()) # get sk root in GCS".
"get sk root in GCS" means "compute (in the GCS referential) the coordinates of the origin of the LCS owning the sketch"
What is the purpose of " Placement.inverse" command ?
Return the inverse placement. Aptly named. :)
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: What is placement "root" and "inverse" terms ?

Post by manos »

openBrain wrote: Thu Sep 22, 2022 11:25 am
Return the inverse placement. Aptly named. :)
You mean that if a placement is applied to an object and then the inverse placement is applied too , the object will be positioned at its initial position ?
Thanks for the answer.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: What is placement "root" and "inverse" terms ?

Post by openBrain »

That's it.
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: What is placement "root" and "inverse" terms ?

Post by manos »

onekk wrote: Thu Sep 22, 2022 11:02 am Regards

Carlo D.
Thank you Carlos. I will study them.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: What is placement "root" and "inverse" terms ?

Post by onekk »

manos wrote: Thu Sep 22, 2022 11:57 am ...
Some more to study:

https://en.wikipedia.org/wiki/Euler_angles

but take in account that at the very end in FC Placement is stored as a quaternion.

https://ntrs.nasa.gov/api/citations/197 ... 019231.pdf

https://en.wikipedia.org/wiki/Quaternion

I admit that I have guessed 10% of the matter, but maybe you are less old than me and more skilled in mathematic.

:oops:

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/
Post Reply