""" Kachelung 35 12.10.2015 """ import c4d import math # Variablen und Konstanten N = 5 # Anzahl Punkte pro Kante r = 1.0 # Kantenlaenge riz = 0.5*r*(2 + math.sqrt(3.0)) # Inkreisradius Zwoelfeck ruz = 0.5*r*( math.sqrt(6.0) + math.sqrt(2.0)) # Umkreisradius Zwoelfeck h = 0.5 * math.sqrt(3.0) * r # Hoehe Dreieck a = r*math.cos(math.pi/12) b = r*math.sin(math.pi/12) Abstand_x = 2*ruz + 2*a Abstand_y = 2*ruz + 2*a NS = 5 # Anzahl Wiederholungen in eine Richtung if NS%2 ==0: # nur ungerade NS zulassen NS = NS +1 Faktor = 1000 # Skalierungsfaktor Zwoelfeck = [] Viereck1 = [] Viereck2 = [] Sexeck = [] Dreieck1 = [] Dreieck2 = [] #Inversion = True Inversion = False def Invers(z): return 1/z def CreateNullobjekt(): obj = c4d.BaseObject(c4d.Onull) # Nullobjekt erzeugen obj.SetName("Kachelung 35") 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) # Dreiecke 1 ********************************************************************* def CreateSplineObjectD1(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*3*(2*NS+1)*(2*NS+1)*4) dt= r/N dtb= 2*b/N zz = 0 # Zaehler Punkte # Dreiecksdaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -15) + complex(ruz, 0) Dreieck1.append(z) for i in range(0,N): z = complex(ruz + a, b -i * dtb) Dreieck1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 195) + complex(ruz + a, -b) Dreieck1.append(z) # Dreieck duplizieren und drehen for i in range(1,4): for j in range(0,3*N): z = Drehung(Dreieck1[j], -90*i) 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): x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,3*N*4): 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)*4) for i in range(0, (2*NS+1)*(2*NS+1)*4): obj.SetSegment(i, 3*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Dreiecke 1") 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)*8) dt= r/N dtb= 2*b/N zz = 0 # Zaehler Punkte # Dreiecksdaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -15) + complex(-a, 0) Dreieck2.append(z) for i in range(0,N): z = complex(0, b -i * dtb) Dreieck2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 195) + complex(0, -b) Dreieck2.append(z) # Dreieck spiegeln for i in range(0,3*N): z = complex(-Dreieck2[i].real, Dreieck2[i].imag) Dreieck2.append(z) # Dreiecke verschieben for i in range(0,3*N*2): Dreieck2[i] = Dreieck2[i] + + complex(-(a + b), ruz + a) # Dreiecke spiegeln for i in range(0,3*N*2): z = complex(-Dreieck2[i].real, Dreieck2[i].imag) Dreieck2.append(z) # Dreieck duplizieren und drehen for i in range(0,3*N*4): z = Drehung(Dreieck2[i], 90) 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): x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,3*N*8): 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)*8) for i in range(0, (2*NS+1)*(2*NS+1)*8): obj.SetSegment(i, 3*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Dreiecke 2") obj.Message(c4d.MSG_UPDATE) return obj # Sechsecke **************************************************************************** def CreateSplineObjectS(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*6*(2*NS+1)*(2*NS+1)*4) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Sechseckdaten erzeugen for i in range(0,N): z = complex(-h, -0.5 * r + i * dt) Sexeck.append(z) for k in range(1,6): for j in range(0,N): z = Drehung(Sexeck[j], 60*k) Sexeck.append(z) # Sechseck verschieben for i in range(0,6*N): Sexeck[i] = Sexeck[i] + complex(riz + h, 0) # Sechseck drehen for i in range(0,6*N): Sexeck[i] = Drehung(Sexeck[i], -45) # Sechseck duplizieren und drehen for k in range(1,4): for j in range(0,6*N): z = Drehung(Sexeck[j], 90*k) Sexeck.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): x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,6*N*4): z = Sexeck[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)*4) for i in range(0, (2*NS+1)*(2*NS+1)*4): obj.SetSegment(i, 6*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Sechsecke") obj.Message(c4d.MSG_UPDATE) return obj # Vierecke 1 ******************************************************************** def CreateSplineObjectQ1(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*(2*NS+1)*(2*NS+1)*8) dt= r/N zz = 0 # Zaehler Punkte # Viereckssdaten erzeugen for i in range(0,N): z = complex(riz + i * dt, -0.5 * r) Viereck1.append(z) for i in range(0,N): z = complex(riz + r, -0.5 * r + i * dt) Viereck1.append(z) for i in range(0,N): z = complex(riz + r - i * dt, 0.5 * r) Viereck1.append(z) for i in range(0,N): z = complex(riz, 0.5 * r - i * dt) Viereck1.append(z) # Viereck drehen for i in range(0,4*N): Viereck1[i] = Drehung(Viereck1[i], -15) # Viereck Spiegeln for i in range(0,4*N): z = complex(Viereck1[i].real, -Viereck1[i].imag) Viereck1.append(z) # Vierecke duplizieren und drehen for k in range(1,4): for j in range(0,8*N): z = Drehung(Viereck1[j], -90*k) Viereck1.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): x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,4*N*8): z = Viereck1[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)*8) for i in range(0, (2*NS+1)*(2*NS+1)*8): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Vierecke 1") obj.Message(c4d.MSG_UPDATE) return obj # Vierecke 2 ******************************************************************** def CreateSplineObjectQ2(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*(2*NS+1)*(2*NS+1)) dt= r/N zz = 0 # Zaehler Punkte # Viereckssdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -0.5 * r) Viereck2.append(z) for i in range(0,N): z = complex(0.5 * r, -0.5 * r + i * dt) Viereck2.append(z) for i in range(0,N): z = complex(0.5 * r - i * dt, 0.5 * r) Viereck2.append(z) for i in range(0,N): z = complex(-0.5 * r, 0.5 * r - i * dt) Viereck2.append(z) # Viereck drehen und verschieben for i in range(0,4*N): Viereck2[i] = Drehung(Viereck2[i], -45) + complex(ruz + a, ruz + a) for k in range(0,2*NS+1): y0 = -Abstand_y*NS + k*Abstand_y for j in range(0,2*NS+1): x0 = -Abstand_x*NS + j*Abstand_x for i in range(0,4*N): z = Viereck2[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, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Vierecke 2") obj.Message(c4d.MSG_UPDATE) return obj # Zwoelfecke ********************************************************************************** def CreateSplineObjectZ(): # Splineobjekte erzeugen obj1 = c4d.BaseObject(c4d.Ospline) obj1.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) # Zwoelfeck drehen for i in range(0,12*N): Zwoelfeck[i] = Drehung(Zwoelfeck[i], -15) for k in range(0,2*NS+1): y0 = -Abstand_y*NS + k*Abstand_y for j in range(0,2*NS+1): 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) obj1.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj1.MakeVariableTag(c4d.Tsegment, (2*NS+1)*(2*NS+1)) for i in range(0, (2*NS+1)*(2*NS+1)): obj1.SetSegment(i, 12*N, True) obj1[c4d.SPLINEOBJECT_CLOSED] = True obj1.SetName("Zwoelfecke") obj1.Message(c4d.MSG_UPDATE) return obj1 def main(): nullobj = CreateNullobjekt() slinobj1 = CreateSplineObjectZ() slinobj2 = CreateSplineObjectQ1() slinobj3 = CreateSplineObjectQ2() slinobj4 = CreateSplineObjectS() slinobj5 = CreateSplineObjectD1() slinobj6 = CreateSplineObjectD2() doc.InsertObject(nullobj, None, None, True) doc.InsertObject(slinobj6, nullobj, None, True) doc.InsertObject(slinobj5, nullobj, None, True) doc.InsertObject(slinobj3, nullobj, None, True) doc.InsertObject(slinobj2, nullobj, None, True) doc.InsertObject(slinobj4, nullobj, None, True) doc.InsertObject(slinobj1, nullobj, None, True) c4d.EventAdd() if __name__=='__main__': main()