as part of my quest to use FreeCAD in a design project of mine I now need to create a flat net of a Goldberg polyhedron. In order to do so I labelled all the faces of the polyhedron in a reasonable manner, and then devised a scheme for the remaining face connectivity, and a recursive function to map all those faces onto the XY plane.
But I'm having trouble with this mapping. See the following screenshot: The idea is that the (planar) Face133 is mapped onto the XY plane such that the selected edge towards Face136 gets located on the Y axis with the vertex v1 closest to the "700" text ending up at (0,0,0).
So the first thing I do is translate all points of Face133 by the vector -v1. So far so good, and you can see the result in the screenshot slightly off the YZ plane.
In a next step I intended to rotate the face around an axis by an angle such that the second vertex v2 of the selected edge gets located on the Y axis.
Code: Select all
def toxy(pp1,pp2,pxy1,pxy2,p1,p2):
# The previous edge pp1->pp2 was mapped onto pxy1->pxy2 (with pxy1.z and pxy2.z being 0).
# Map the edge p1->p2 accordingly by translation and rotation.
# 1. Translate p1 and p2 by the vector that positions pp1 onto pxy1
xy1 = p1+(pxy1-pp1)
xy2 = p2+(pxy1-pp1)
# 2. Rotate p1 and p2 around the axis through pp1 and perpendicular to the plane pp1->pp2 and pxy1->pxy2
# by the angle between pp1->pp2 and pxy1->pxy2, i.e. perform the rotation that keeps pp1 at pxy1 and maps pp2 onto pxy2
rot = App.Rotation(pp2-pp1,pxy2-pxy1)
#angle = (pp2-pp1).getAngle(pxy2-pxy1)
#axis = (pp2-pp1).cross(pxy2-pxy1)
#rot = App.Rotation(axis,Radian=angle)
xy1 = rot.multVec(xy1)
xy2 = rot.multVec(xy2)
# Now xy1.z and xy2.z should be 0. But alas, they are not!
return (xy1,xy2)
Any help is appreciated.
Kind regards,
Sebastian