""" Kachelung 40 10.09.2015 """ import c4d import math # Variablen und Konstanten N = 5 # Anzahl Punkte pro Kante r = 1.0 # Kantenlaenge h = 0.5*r*math.sqrt(5 + 2*math.sqrt(5.0)) # Hoehe Fuenfeck h1 = 0.25*r*math.sqrt(10 + 2*math.sqrt(5.0)) # Hoehe Dreieck Raute ri = 0.1*r*math.sqrt(25 + 10*math.sqrt(5.0)) # Inkreisradius Fuenfeck ru = 0.1*r*math.sqrt(50 + 10*math.sqrt(5.0)) # Umkreisradius Fuenfeck a = 0.25*r*(math.sqrt(5.0) - 1) Abstand_x = r + 2*a Abstand_y = h + h1 Versatz_x = r + 2*a NS = 1 # Anzahl Wiederholungen in eine Richtung Faktor = 1000 # Skalierungsfaktor Fuenfeck0 = [] Fuenfeck1 = [] Fuenfeck2 = [] Fuenfeck3 = [] Fuenfeck4 = [] Raute1 = [] Raute2 = [] Raute3 = [] Raute4 = [] #Inversion = True Inversion = False def Invers(z): if abs(z) == 0: z = complex(z.real, z.imag + 0.0001) return 1/z def CreateNullobjekt(): obj = c4d.BaseObject(c4d.Onull) # Nullobjekt erzeugen obj.SetName("Kachelung 40") 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) # Rauten 4 *************************************************************************************** def CreateSplineObjectR4(): SS = int(0.5*(NS**2 + 3*NS)) # Summe Segment obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*SS*5) dt= r/N zz = 0 # Zaehler Punkte # Rautendaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -72) + complex(-a, 0) Raute4.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 72) + complex(0, h1) Raute4.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 108) + complex(a, 0) Raute4.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -108) + complex(0, -h1) Raute4.append(z) for k in range(0,NS): y0 = ri + 2*h1 + 2*h + k*(h + h1) for j in range(0,k+2): x0 = j*Abstand_x - (k+1)*(0.5*r + a) for i in range(0,4*N): z = Drehung(Raute4[i] + complex(x0, y0), 36) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 # Segment duplizieren und drehen for k in range(1, 5): for i in range(0,4*N*SS): v = obj.GetPoint(i) z = Drehung(complex(v.x, v.y), -72*k) obj.SetPoint(zz, c4d.Vector(z.real, z.imag, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, SS*5) for i in range(0, SS*5): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Rauten 4") obj.Message(c4d.MSG_UPDATE) return obj # Rauten 3 *************************************************************************************** def CreateSplineObjectR3(): SS = int(0.5*(NS**2 + 3*NS)) # Summe Segment obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*SS*5) dt= r/N zz = 0 # Zaehler Punkte # Rautendaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -72) + complex(-a, 0) Raute3.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 72) + complex(0, h1) Raute3.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 108) + complex(a, 0) Raute3.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -108) + complex(0, -h1) Raute3.append(z) for k in range(0,NS): y0 = ru + 2*h1 + h + k*(h + h1) for j in range(0,k+2): x0 = j*Abstand_x - (k+1)*(0.5*r + a) for i in range(0,4*N): z = Raute3[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 # Segment duplizieren und drehen for k in range(1, 5): for i in range(0,4*N*SS): v = obj.GetPoint(i) z = Drehung(complex(v.x, v.y), -72*k) obj.SetPoint(zz, c4d.Vector(z.real, z.imag, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, SS*5) for i in range(0, SS*5): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Rauten 3") obj.Message(c4d.MSG_UPDATE) return obj # Rauten 2 *************************************************************************************** def CreateSplineObjectR2(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*5) dt= r/N zz = 0 # Zaehler Punkte # Rautendaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -72) + complex(-a, 0) Raute2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 72) + complex(0, h1) Raute2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 108) + complex(a, 0) Raute2.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -108) + complex(0, -h1) Raute2.append(z) # Raute verschieben und drehen for i in range(0,4*N): Raute2[i] = Drehung(Raute2[i] + complex(0, ri + h + h1), 36) # Raute duplizieren und drehen for k in range(1,5): for i in range(0,4*N): z = Drehung(Raute2[i], 72*k) Raute2.append(z) for i in range(0,4*N*5): z = Raute2[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, 5) for i in range(0, 5): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Rauten 2") obj.Message(c4d.MSG_UPDATE) return obj # Rauten 1 *************************************************************************************** def CreateSplineObjectR1(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*5) dt= r/N zz = 0 # Zaehler Punkte # Rautendaten erzeugen for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -72) + complex(-a, 0) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 72) + complex(0, h1) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 108) + complex(a, 0) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -108) + complex(0, -h1) Raute1.append(z) # Raute verschieben for i in range(0,4*N): Raute1[i] = Raute1[i] + complex(0, ru + h1) # Raute duplizieren und drehen for k in range(1,5): for i in range(0,4*N): z = Drehung(Raute1[i], 72*k) Raute1.append(z) for i in range(0,4*N*5): z = Raute1[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, 5) for i in range(0, 5): obj.SetSegment(i, 4*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Rauten 1") obj.Message(c4d.MSG_UPDATE) return obj # Fuenfecke 4 ************************************************************** def CreateSplineObjectF4(): # Splineobjekte erzeugen SS = int(0.5*(NS**2 + NS)) # Summe Segment obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*10*SS*5) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -ri) Fuenfeck4.append(z) for k in range(1,5): for j in range(0,N): z = Drehung(Fuenfeck4[j], -72*k) Fuenfeck4.append(z) # Fuenfeck verschieben for i in range(0,5*N): Fuenfeck4[i] = Fuenfeck4[i] + complex(0, ri) # Fuenfeck spiegeln for i in range(0,5*N): z = complex(Fuenfeck4[i].real, -Fuenfeck3[i].imag) Fuenfeck4.append(z) for k in range(0,NS): y0 = ri + 2*h1 + 2*h + k*(h + h1) for j in range(0,k+1): x0 = j*Abstand_x - (k)*(0.5*r + a) for i in range(0,5*N*2): z = Drehung(Fuenfeck4[i] + complex(x0, y0), 36) if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 # Segment duplizieren und drehen for k in range(1, 5): for i in range(0,10*N*SS): v = obj.GetPoint(i) z = Drehung(complex(v.x, v.y), -72*k) obj.SetPoint(zz, c4d.Vector(z.real, z.imag, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, SS*10) for i in range(0, SS*10): obj.SetSegment(i, 5*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 4") obj.Message(c4d.MSG_UPDATE) return obj # Fuenfecke 3 ************************************************************** def CreateSplineObjectF3(): # Splineobjekte erzeugen SS = int(0.5*(NS**2 + 5*NS)) # Summe Segment obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*10*SS*5) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -ri) Fuenfeck3.append(z) for k in range(1,5): for j in range(0,N): z = Drehung(Fuenfeck3[j], -72*k) Fuenfeck3.append(z) # Fuenfeck verschieben for i in range(0,5*N): Fuenfeck3[i] = Fuenfeck3[i] + complex(0, ri) # Fuenfeck spiegeln for i in range(0,5*N): z = complex(Fuenfeck3[i].real, -Fuenfeck3[i].imag) Fuenfeck3.append(z) for k in range(0,NS): y0 = ru + 2*h1 + h + k*(h + h1) for j in range(0,k+3): x0 = j*Abstand_x - (k+2)*(0.5*r + a) for i in range(0,5*N*2): z = Fuenfeck3[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 # Segment duplizieren und drehen for k in range(1, 5): for i in range(0,10*N*SS): v = obj.GetPoint(i) z = Drehung(complex(v.x, v.y), -72*k) obj.SetPoint(zz, c4d.Vector(z.real, z.imag, 0.0)) zz = zz + 1 obj.MakeVariableTag(c4d.Tsegment, SS*10) for i in range(0, SS*10): obj.SetSegment(i, 5*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 3") obj.Message(c4d.MSG_UPDATE) return obj # Fuenfeck 0 ************************************************************** def CreateSplineObjectF0(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*5) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -ri) Fuenfeck0.append(z) for k in range(1,5): for j in range(0,N): z = Drehung(Fuenfeck0[j], -72*k) Fuenfeck0.append(z) for i in range(0,5*N*1): z = Fuenfeck0[i] if Inversion: z = Invers(z) obj.SetPoint(zz, c4d.Vector(z.real*Faktor, z.imag*Faktor, 0.0)) zz = zz + 1 obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 0") obj.Message(c4d.MSG_UPDATE) return obj # Fuenfecke 1 ************************************************************** def CreateSplineObjectF1(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*5*5) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten erzeugen for i in range(0,N): z = complex(-0.5 * r + i * dt, -ri) Fuenfeck1.append(z) for k in range(1,5): for j in range(0,N): z = Drehung(Fuenfeck1[j], -72*k) Fuenfeck1.append(z) # Fuenfeck spiegeln und verschieben for i in range(0,5*N): Fuenfeck1[i] = complex(Fuenfeck1[i].real, -Fuenfeck1[i].imag) + complex(0, -2*ri) #Fuenfeck1.append(z) # Fuenfeck duplizieren und drehen for k in range(1,5): for j in range(0, 5*N): z = Drehung(Fuenfeck1[j], 72*k) Fuenfeck1.append(z) for i in range(0,5*N*5): z = Fuenfeck1[i] 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, 5) for i in range(0, 5): obj.SetSegment(i, 5*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 1") obj.Message(c4d.MSG_UPDATE) return obj # Fuenfecke 2 ************************************************************** def CreateSplineObjectF2(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*5*10) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten aus Fuenfeck0 erzeugen for i in range(0,5*N): z = Fuenfeck0[i] + complex(-0.5*r-a, h + h1) Fuenfeck2.append(z) # Fuenfeck duplizieren und spiegeln for i in range(0,5*N): z = complex(-Fuenfeck2[i].real, Fuenfeck2[i].imag) Fuenfeck2.append(z) # Fuenfeck duplizieren und drehen for k in range(1,5): for j in range(0, 5*N*2): z = Drehung(Fuenfeck2[j], 72*k) Fuenfeck2.append(z) for i in range(0,5*N*10): z = Fuenfeck2[i] 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, 10) for i in range(0, 10): obj.SetSegment(i, 5*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 2") obj.Message(c4d.MSG_UPDATE) return obj def main(): nullobj = CreateNullobjekt() slinobj1 = CreateSplineObjectF0() slinobj2 = CreateSplineObjectF1() slinobj3 = CreateSplineObjectF2() slinobj4 = CreateSplineObjectF3() slinobj5 = CreateSplineObjectF4() slinobj6 = CreateSplineObjectR1() slinobj7 = CreateSplineObjectR2() slinobj8 = CreateSplineObjectR3() slinobj9 = CreateSplineObjectR4() doc.InsertObject(nullobj, None, None, True) doc.InsertObject(slinobj9, nullobj, None, True) doc.InsertObject(slinobj8, nullobj, None, True) doc.InsertObject(slinobj7, nullobj, None, True) doc.InsertObject(slinobj6, nullobj, None, True) doc.InsertObject(slinobj5, nullobj, None, True) doc.InsertObject(slinobj4, nullobj, None, True) doc.InsertObject(slinobj3, nullobj, None, True) doc.InsertObject(slinobj2, nullobj, None, True) doc.InsertObject(slinobj1, nullobj, None, True) c4d.EventAdd() if __name__=='__main__': main()