Assumed:
- two identical wire
- made only from straight edges
- same start point
- the rest could be some how turned in 3D orbit
I would like to somehow save what is needed to move and turn one wire into the other. As input I only have the shapes of the wire.
Someone know how to do this?
placement transformation
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: placement transformation
This should do it :
Assuming that the first 3 vertexes of the shape correctly define a plane (not coincident, nor colinear)
Code: Select all
def get_relative_placement(shape1, shape2):
"returns the placement that must be applied to shape1 to move it to shape_2"
plane1 = Part.Plane(*[v.Point for v in shape1.Vertexes[0:3]])
plane2 = Part.Plane(*[v.Point for v in shape2.Vertexes[0:3]])
pl1 = FreeCAD.Placement(plane1.Position, plane1.Rotation)
pl2 = FreeCAD.Placement(plane2.Position, plane2.Rotation)
return pl2.multiply(pl1.inverse())
Re: placement transformation
Great! Exactly what I need
Where did you get it from, or did you just coded it?
Where did you get it from, or did you just coded it?
Re: placement transformation
just coded
Re: placement transformation
Code: Select all
obj.Placement = myRelativePlacment.multiply(obj.Placement)