""" Kachelung 50 10.09.2015 """ import c4d import math # Variablen und Konstanten N = 35 # Anzahl Punkte pro Kante r = 1.0 # Kantenlaenge riz = 0.5*r*(2 + math.sqrt(3.0)) # Inkreisradius Zwoelfeck ris = 0.5 * math.sqrt(3.0) * r # Inkreisradius Sechseck h = (2*riz + 4*r)*0.5*math.sqrt(3.0) # Abstand_x = 2*riz + 4*r Abstand_y = h Versatz_x = riz + 2*r NS = 5 # Anzahl Wiederholungen in eine Richtung if NS%2 ==0: # nur ungerade NS zulassen NS = NS +1 Faktor = 1000 # Skalierungsfaktor Zwoelfeck = [] Viereck = [] Sexeck1 = [] Sexeck2 = [] Dreieck1 = [] Dreieck2 = [] Inversion = True #Inversion = False def Invers(z): return 1/z def CreateNullobjekt(): obj = c4d.BaseObject(c4d.Onull) # Nullobjekt erzeugen obj.SetName("Kachelung 50") obj.Message(c4d.MSG_UPDATE) return obj def Drehung(z, Grad): Winkel = Grad * math.pi/180 x = z.real y = z.imag x1 = math.cos(Winkel) * x + math.sin(Winkel) * y y1 = -math.sin(Winkel) * x + math.cos(Winkel) * y return complex(x1, y1) # Sechsecke 2 ******************************************************************************** def CreateSplineObjectS2(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*6*(2*NS+1)*(2*NS+1)*2) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Sechseckdaten erzeugen for i in range(0,N): z = complex( -0.5 * r + i * dt, ris) Sexeck2.append(z) for k in range(1,6): for j in range(0,N): z = Drehung(Sexeck2[j], 60*k) Sexeck2.append(z) # Sechseck verschieben for i in range(0,6*N): Sexeck2[i] = Sexeck2[i] + complex(riz + 2*r, 0.5*r + 2*ris) # Sechseck spiegeln for i in range(0,6*N): z = complex(Sexeck2[i].real, -Sexeck2[i].imag) Sexeck2.append(z) for k in range(0,2*NS+1): y0 = -NS*Abstand_y + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,6*N*2): z = Sexeck2[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)*2) for i in range(0, (2*NS+1)*(2*NS+1)*2): obj.SetSegment(i, 6*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Sechsecke 2") obj.Message(c4d.MSG_UPDATE) return obj # Dreiecke 2 ************************************************************************** def CreateSplineObjectD2(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*3*(2*NS+1)*(2*NS+1)*6) dt= r/N zz = 0 # Zaehler Punkte # Dreiecksdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, 0) Dreieck2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -120) + complex(0.5*r, 0) Dreieck2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 120) + complex(0, ris) Dreieck2.append(z) # Dreieck verschieben for i in range(0,3*N): Dreieck2[i] = Dreieck2[i] + complex(riz + 2*r, -0.5*r - ris) # Dreieck duplizieren und spiegeln for i in range(0,3*N): z = complex(Dreieck2[i].real, -Dreieck2[i].imag) Dreieck2.append(z) # Dreiecke duplizieren und drehen for i in range(0,3*N*2): z = Drehung( Dreieck2[i], 60) Dreieck2.append(z) for i in range(0,3*N*2): z = Drehung( Dreieck2[i], -60) Dreieck2.append(z) for k in range(0,2*NS+1): y0 = -Abstand_y*NS + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,3*N*6): z = Dreieck2[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)*6) for i in range(0, (2*NS+1)*(2*NS+1)*6): obj.SetSegment(i, 3*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Dreiecke 2") obj.Message(c4d.MSG_UPDATE) return obj # Dreiecke 1 ************************************************************************** def CreateSplineObjectD1(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*3*(2*NS+1)*(2*NS+1)*12) dt= r/N zz = 0 # Zaehler Punkte # Dreiecksdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, 0) Dreieck1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -120) + complex(0.5*r, 0) Dreieck1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 120) + complex(0, ris) Dreieck1.append(z) # Dreieck verschieben for i in range(0,3*N): Dreieck1[i] = Dreieck1[i] + complex(riz + 1.5*r, 0.5*r) # Dreieck verschieben for i in range(0,3*N): z = Dreieck1[i] + complex(r, 0) Dreieck1.append(z) # Dreiecke duplizieren und spiegeln for i in range(0,3*N*2): z = complex(Dreieck1[i].real, -Dreieck1[i].imag) Dreieck1.append(z) # Dreiecke duplizieren und drehen for i in range(0,3*N*4): z = Drehung(Dreieck1[i], 60) Dreieck1.append(z) for i in range(0,3*N*4): z = Drehung(Dreieck1[i], -60) Dreieck1.append(z) for k in range(0,2*NS+1): y0 = -Abstand_y*NS + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,3*N*12): z = Dreieck1[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)*12) for i in range(0, (2*NS+1)*(2*NS+1)*12): obj.SetSegment(i, 3*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Dreiecke 1") obj.Message(c4d.MSG_UPDATE) return obj # Sechsecke 1 ******************************************************************************** def CreateSplineObjectS1(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*6*(2*NS+1)*(2*NS+1)*6) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Sechseckdaten erzeugen for i in range(0,N): z = complex(ris, -0.5 * r + i * dt) Sexeck1.append(z) for k in range(1,6): for j in range(0,N): z = Drehung(Sexeck1[j], -60*k) Sexeck1.append(z) # Sechseck verschieben for i in range(0,6*N): Sexeck1[i] = Sexeck1[i] + complex(riz + ris, 0) # Sechseck drehen for i in range(0,6*N): Sexeck1[i] = Drehung(Sexeck1[i], -30) # Sechseck duplizieren und drehen for k in range(1,6): for j in range(0,6*N): z = Drehung(Sexeck1[j], -60*k) Sexeck1.append(z) for k in range(0,2*NS+1): y0 = -NS*Abstand_y + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,6*N*6): z = Sexeck1[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)*6) for i in range(0, (2*NS+1)*(2*NS+1)*6): obj.SetSegment(i, 6*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Sechsecke 1") obj.Message(c4d.MSG_UPDATE) return obj # Zwoelfecke ************************************************************************************* def CreateSplineObjectZ(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*12*(2*NS+1)*(2*NS+1)) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Zwoelfeckdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -riz) Zwoelfeck.append(z) for k in range(1,12): for j in range(0,N): z = Drehung(Zwoelfeck[j], -30*k) Zwoelfeck.append(z) for k in range(0,2*NS+1): y0 = -NS*Abstand_y + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,12*N): z = Zwoelfeck[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)) for i in range(0, (2*NS+1)*(2*NS+1)): obj.SetSegment(i, 12*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Zwölfecke") obj.Message(c4d.MSG_UPDATE) return obj # Vierecke ********************************************************************************** def CreateSplineObjectQ(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*(2*NS+1)*(2*NS+1)*12) dt= r/N zz = 0 # Zaehler Punkte # Viereckssdaten erzeugen for i in range(0,N): z = complex(riz + i * dt, -0.5 * r) Viereck.append(z) for i in range(0,N): z = complex(riz + r, -0.5 * r + i * dt) Viereck.append(z) for i in range(0,N): z = complex(riz + r - i * dt, 0.5 * r) Viereck.append(z) for i in range(0,N): z = complex(riz, 0.5 * r - i * dt) Viereck.append(z) # Viereck duplizieren und verschieben for i in range(0,4*N): z = Viereck[i] + complex(r, 0) Viereck.append(z) for i in range(0,4*N): z = Viereck[i] + complex(2*r, 0) Viereck.append(z) for i in range(0,4*N): z = Viereck[i] + complex(3*r, 0) Viereck.append(z) # Vierecke duplizieren und drehen for i in range(0,4*N*4): z = Drehung(Viereck[i], 60) Viereck.append(z) for i in range(0,4*N*4): z = Drehung(Viereck[i], -60) Viereck.append(z) for k in range(0,2*NS+1): y0 = -NS*Abstand_y + k*Abstand_y for j in range(0,2*NS+1): if k%2 == 0.0: x0 = -Abstand_x*NS + j*Abstand_x + Versatz_x else: x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,4*N*12): z = Viereck[i] + complex(x0, y0) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)*12) for i in range(0, (2*NS+1)*(2*NS+1)*12): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Vierecke") obj.Message(c4d.MSG_UPDATE) return obj def main(): nullobj = CreateNullobjekt() slinobj1 = CreateSplineObjectZ() slinobj2 = CreateSplineObjectQ() slinobj3 = CreateSplineObjectS1() slinobj6 = CreateSplineObjectS2() slinobj4 = CreateSplineObjectD1() slinobj5 = CreateSplineObjectD2() doc.InsertObject(nullobj, None, None, True) doc.InsertObject(slinobj5, nullobj, None, True) doc.InsertObject(slinobj4, nullobj, None, True) doc.InsertObject(slinobj2, nullobj, None, True) doc.InsertObject(slinobj6, nullobj, None, True) doc.InsertObject(slinobj3, nullobj, None, True) doc.InsertObject(slinobj1, nullobj, None, True) c4d.EventAdd() if __name__=='__main__': main()