Bringing out the big guns! Since the Goldberg Polyhedron is convex, it is the convex hull of its vertices.
Code: Select all
import Part
import numpy as np
from scipy.spatial import ConvexHull
def dualofsphtriangle(n1, n2, n3):
''' Dual vertex location from triangle'''
return (n1.cross(n2) + n2.cross(n3) + n3.cross(n1))/n1.dot(n2.cross(n3))
def vToNpArray(vectorList):
return np.array([[v.x, v.y, v.z] for v in vectorList])
def vListToWirelist(vectorList):
hull = ConvexHull(vToNpArray(vectorList))
wires = []
for simplex in hull.simplices:
points = [vectorList[i] for i in simplex]
points.append(vectorList[simplex[0]])# make cyclic
wires.append(Part.makePolygon(points))
return wires
def makeDual(shp , r):
dualVertexLocs = [(r**2) * dualofsphtriangle(*[v.Point for v in face.Vertexes[0:3]]) for face in shp.Faces]
wires = vListToWirelist(dualVertexLocs)
faces = [Part.Face(wire) for wire in wires]
shell = Part.Shell(faces).removeSplitter()
return shell
doc = App.ActiveDocument
shp = doc.getObject('GoldbergGeodesicSphere').Shape
r = shp.Vertexes[0].Point.Length
shell = makeDual(shp , r)
Part.show(shell, "GoldbergPolyhedron")
#dual of dual
shelldual = makeDual(shell , r)
Part.show(shelldual, "DualDualGoldbergGeodesicSphere")