""" Johnson Körperr J40 22.02.2021 www.3d-meier.de http://dmccooey.com/polyhedra/ElongatedPentagonalOrthocupolarotunda.html """ import c4d import math # Variablen und Konstanten Titel = 'Johnson Körper J40' # Name NP = 35 # Anzahl Punkte N3 = 15 # Anzahl Dreiecke N4 = 15 # Anzahl Vierecke N5 = 7 # Anzahl Fuenfecke Radius = 2 # Radius der Eckpunktkugeln C0 = math.sqrt(10 * (5 - math.sqrt(5))) / 20 C1 = math.sqrt(10 * (5 + math.sqrt(5))) / 20 C2 = math.sqrt(5 * (5 + 2 * math.sqrt(5))) / 10 C3 = (1 + math.sqrt(5)) / 4 C4 = math.sqrt(10 * (5 + math.sqrt(5))) / 10 C5 = math.sqrt(2 * (5 + math.sqrt(5))) / 4 C6 = (5 + math.sqrt(10 * (5 - math.sqrt(5)))) / 10 C7 = math.sqrt(10 * (25 + 11 * math.sqrt(5))) / 20 C8 = (3 + math.sqrt(5)) / 4 C9 = (5 + math.sqrt(10 * (5 + math.sqrt(5)))) / 10 C10 = math.sqrt(5 * (5 + 2 * math.sqrt(5))) / 5 C11 = math.sqrt(5 + 2 * math.sqrt(5)) / 2 C12 = (1 + math.sqrt(5)) / 2 C13 = (5 + 2*math.sqrt(5*(5 + 2*math.sqrt(5)))) / 10 Punkte = [( C12, 0.5, 0.0), ( C12, -0.5, 0.0), (-C12, 0.5, 0.0), (-C12, -0.5, 0.0), ( C8, 0.5, C5), ( C8, -0.5, C5), ( C8, 0.5, -C5), ( C8, -0.5, -C5), ( -C8, 0.5, C5), ( -C8, -0.5, C5), ( -C8, 0.5, -C5), ( -C8, -0.5, -C5), ( 0.5, 0.5, C11), ( 0.5, -0.5, C11), ( 0.5, 0.5, -C11), ( 0.5, -0.5, -C11), (-0.5, 0.5, C11), (-0.5, -0.5, C11), (-0.5, 0.5, -C11), (-0.5, -0.5, -C11), ( C8, C9, -C1), ( -C8, C9, -C1), ( C3, C9, C7), ( -C3, C9, C7), ( 0.0, C9, -C10), ( C3, C13, C0), ( -C3, C13, C0), ( 0.5, C13, -C2), (-0.5, C13, -C2), ( 0.0, C13, C4), ( C3, -C6, C0), ( -C3, -C6, C0), ( 0.5, -C6, -C2), (-0.5, -C6, -C2), ( 0.0, -C6, C4)] Dreiecke = [( 22, 4, 12, 12 ), ( 23, 16, 8, 8 ), ( 21, 2, 10, 10 ), ( 24, 18, 14, 14 ), ( 20, 6, 0, 0 ), ( 22, 29, 25, 25 ), ( 23, 26, 29, 29 ), ( 21, 28, 26, 26 ), ( 24, 27, 28, 28 ), ( 20, 25, 27, 27 ), ( 5, 1, 30, 30 ), ( 7, 15, 32, 32 ), ( 19, 11, 33, 33 ), ( 3, 9, 31, 31 ), ( 17, 13, 34, 34 )] Vierecke = [( 5, 30, 34, 13 ), ( 7, 32, 30, 1 ), ( 19, 33, 32, 15 ), ( 3, 31, 33, 11 ), ( 17, 34, 31, 9 ), ( 5, 13, 12, 4 ), ( 7, 1, 0, 6 ), ( 19, 15, 14, 18 ), ( 3, 11, 10, 2 ), ( 17, 9, 8, 16 ), ( 5, 4, 0, 1 ), ( 7, 6, 14, 15 ), ( 19, 18, 10, 11 ), ( 3, 2, 8, 9 ), ( 17, 16, 12, 13 )] Fuenfecke = [( 25, 29, 26, 28, 27 ), ( 30, 32, 33, 31, 34 ), ( 22, 25, 20, 0, 4 ), ( 23, 29, 22, 12, 16 ), ( 21, 26, 23, 8, 2 ), ( 24, 28, 21, 10, 18 ), ( 20, 27, 24, 14, 6 )] Faktor = 100 # Skalierungsfaktor k = 1 # Korrekturfaktor fuer Kantenlaenge 1 #************************************************************************ def CreateNullobjekt1(): obj = c4d.BaseObject(c4d.Onull) obj.SetName(Titel) obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateNullobjekt2(): obj = c4d.BaseObject(c4d.Onull) obj.SetName('Ecken') obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateNullobjekt3(): obj = c4d.BaseObject(c4d.Onull) obj.SetName('Kanten') obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateNullobjekt4(): obj = c4d.BaseObject(c4d.Onull) obj.SetName('Polygone') obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateDreiecke(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(NP,N3) obj.SetName('Dreiecke') # Punkte uebergeben for i in xrange(NP): obj.SetPoint(i, c4d.Vector(Punkte[i][0]*Faktor*k, Punkte[i][1]*Faktor*k, Punkte[i][2]*Faktor*k)) # Dreiecke setzen for i in xrange(N3): obj.SetPolygon( i, c4d.CPolygon(Dreiecke[i][0], Dreiecke[i][1], Dreiecke[i][2], Dreiecke[i][3])) obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateVierecke(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(NP, N4) obj.SetName('Vierecke') # Punkte uebergeben for i in xrange(NP): obj.SetPoint(i, c4d.Vector(Punkte[i][0]*Faktor*k, Punkte[i][1]*Faktor*k, Punkte[i][2]*Faktor*k)) # Vierecke setzen for i in xrange(N4): obj.SetPolygon(i, c4d.CPolygon(Vierecke[i][0], Vierecke[i][1], Vierecke[i][2], Vierecke[i][3])) obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateFuenfecke(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(NP, N5*2) obj.SetName('Fünfecke') # Punkte uebergeben for i in xrange(NP): obj.SetPoint(i, c4d.Vector(Punkte[i][0]*Faktor*k, Punkte[i][1]*Faktor*k, Punkte[i][2]*Faktor*k)) zz = 0 # Zaehler fuer Polygone zuruecksetzen for i in xrange(N5): obj.SetPolygon(zz, c4d.CPolygon(Fuenfecke[i][0], Fuenfecke[i][1], Fuenfecke[i][2], Fuenfecke[i][4])) zz = zz + 1 obj.SetPolygon(zz, c4d.CPolygon(Fuenfecke[i][2], Fuenfecke[i][3], Fuenfecke[i][4], Fuenfecke[i][4])) zz = zz + 1 obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateSplineDreiecke(): obj = c4d.BaseObject(c4d.Ospline) obj.SetName("Spline-Dreiecke") obj.ResizeObject(N3*3) zz = 0 for i in xrange(N3): for j in xrange(3): x = Punkte[Dreiecke[i][j]][0] y = Punkte[Dreiecke[i][j]][1] z = Punkte[Dreiecke[i][j]][2] obj.SetPoint(zz, c4d.Vector(x*Faktor*k, y*Faktor*k, z*Faktor*k)) zz = zz + 1 # Segmente erzeugen obj.MakeVariableTag(c4d.Tsegment, N3) for i in range(0, N3): obj.SetSegment(i, 3, True) # Spline schliessen obj[c4d.SPLINEOBJECT_CLOSED] = True# obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateSplineVierecke(): obj = c4d.BaseObject(c4d.Ospline) obj.SetName("Spline-Vierecke") obj.ResizeObject(N4*4) zz = 0 for i in xrange(N4): for j in xrange(4): x = Punkte[Vierecke[i][j]][0] y = Punkte[Vierecke[i][j]][1] z = Punkte[Vierecke[i][j]][2] obj.SetPoint(zz, c4d.Vector(x*Faktor*k, y*Faktor*k, z*Faktor*k)) zz = zz + 1 # Segmente erzeugen obj.MakeVariableTag(c4d.Tsegment, N4) for i in range(0, N4): obj.SetSegment(i, 4, True) # Spline schliessen obj[c4d.SPLINEOBJECT_CLOSED] = True obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def CreateSplineFuenfecke(): obj = c4d.BaseObject(c4d.Ospline) obj.SetName("Spline-Fünfecke") obj.ResizeObject(N5*5) zz = 0 for i in xrange(N5): for j in xrange(5): x = Punkte[Fuenfecke[i][j]][0] y = Punkte[Fuenfecke[i][j]][1] z = Punkte[Fuenfecke[i][j]][2] obj.SetPoint(zz, c4d.Vector(x*Faktor*k, y*Faktor*k, z*Faktor*k)) zz = zz + 1 # Segmente erzeugen obj.MakeVariableTag(c4d.Tsegment, N5) for i in range(0, N5): obj.SetSegment(i, 5, True) # Spline schliessen obj[c4d.SPLINEOBJECT_CLOSED] = True obj.Message(c4d.MSG_UPDATE) return obj #************************************************************************ def main(): nullobj1 = CreateNullobjekt1() nullobj2 = CreateNullobjekt2() # Ecken nullobj3 = CreateNullobjekt3() # Kanten nullobj4 = CreateNullobjekt4() # Polygone plyobj1 = CreateDreiecke() plyobj2 = CreateVierecke() plyobj3 = CreateFuenfecke() splobj1 = CreateSplineDreiecke() splobj2 = CreateSplineVierecke() splobj3 = CreateSplineFuenfecke() doc.InsertObject(nullobj1, None, None, True) doc.InsertObject(nullobj4, nullobj1, None, True) doc.InsertObject(nullobj3, nullobj1, None, True) doc.InsertObject(nullobj2, nullobj1, None, True) doc.InsertObject(splobj3, nullobj3, None, True) doc.InsertObject(splobj2, nullobj3, None, True) doc.InsertObject(splobj1, nullobj3, None, True) doc.InsertObject(plyobj3, nullobj4, None, True) doc.InsertObject(plyobj2, nullobj4, None, True) doc.InsertObject(plyobj1, nullobj4, None, True) # Kugeln auf Eckpunkte setzen for i in range(0, NP): obj = c4d.BaseObject(c4d.Osphere) obj[c4d.PRIM_SPHERE_RAD] = Radius obj.SetName(str(i)) x = Punkte[i][0] y = Punkte[i][1] z = Punkte[i][2] obj.SetAbsPos(c4d.Vector(x*Faktor*k, y*Faktor*k, z*Faktor*k)) doc.InsertObject(obj, nullobj2, None, True) c4d.EventAdd() if __name__=='__main__': main()