""" Kachelung 26 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 a = 0.25*r*(math.sqrt(5.0) - 1) Abstand_x = r + 2*a Abstand_y = h + h1 Versatz_x = 0.5*r + a NS = 7 # Anzahl Wiederholungen in eine Richtung if NS%2 ==0: # nur ungerade NS zulassen NS = NS +1 Faktor = 1000 # Skalierungsfaktor Fuenfeck1 = [] Fuenfeck2 = [] Raute1 = [] #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 26") 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) # Fuenfecke 1 ************************************************************** def CreateSplineObjectF1(): # Splineobjekte erzeugen obj = c4d.BaseObject(c4d.Ospline) obj.ResizeObject(N*5*(2*NS+1)*(2*NS+1)) 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 verschieben for i in range(0,5*N): Fuenfeck1[i] = Fuenfeck1[i] + complex(0, ri) 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,5*N): z = Fuenfeck1[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, 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*(2*NS+1)*(2*NS+1)) dt= r/N # Unterteilung Kante zz = 0 # Zaehler Punkte # Fuenfeckdaten aus Fuenfeck1 erzeugen for i in range(0,5*N): z = complex(Fuenfeck1[i].real, -Fuenfeck1[i].imag) Fuenfeck2.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,5*N): z = Fuenfeck2[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, 5*N, True) obj[c4d.SPLINEOBJECT_CLOSED] = True obj.SetName("Fuenfecke 2") obj.Message(c4d.MSG_UPDATE) return obj # Rauten *************************************************************************************** def CreateSplineObjectR(): obj = c4d.BaseObject(c4d.Ospline) # Splineobjekt erzeugen obj.ResizeObject(N*4*(2*NS+1)*(2*NS+1)) 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(0.5*r, 0) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 72) + complex(0.5*r + a, h1) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, 108) + complex(0.5*r + 2*a, 0) Raute1.append(z) for i in range(0,N): z = complex(i * dt, 0) z = Drehung(z, -108) + complex(0.5*r + a, -h1) Raute1.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,4*N): 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, (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("Rauten") obj.Message(c4d.MSG_UPDATE) return obj def main(): nullobj = CreateNullobjekt() slinobj1 = CreateSplineObjectF1() slinobj2 = CreateSplineObjectF2() slinobj3 = CreateSplineObjectR() doc.InsertObject(nullobj, None, 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()