""" Pentigree 27.01.2022 (c) Jürgen Meier (www.3d-meier.de) """ import c4d import random import math # Variablen und Konstanten Titel = 'Pentigree' # Name N = 10000000 # Anzahl Punkte Nv = 100 # Anzahl Punkte verwerfen dx = 0.50 # Breite Polygon dy = 0.50 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor r = (3 - math.sqrt(5.0))/2.0 # Konstante a = r*math.cos(math.radians(36)) b = r*math.sin(math.radians(36)) c = r*math.cos(math.radians(108)) d = r*math.sin(math.radians(108)) e = a - r*math.cos(math.radians(72)) f = b + r*math.sin(math.radians(72)) g = e + a h = f - b k = g - r*math.cos(math.radians(72)) l = h - r*math.sin(math.radians(72)) m = k + a n = l - b def CreatePolygonObject(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(4*N, N) obj.SetName(Titel) # Startwert der Berechnung x = 0.5 xa = x y = 0.5 # Zaehler fuer Punkte setzten zz = 0 # Zaehler fuer Polygone setzten zzz = 0 for i in xrange(0,Nv): zufall = random.randint(0,5) if zufall == 0: x = a*xa - b*y y = b*xa + a*y if zufall == 1: x = c*xa - d*y + a y = d*xa + c*y + b if zufall == 2: x = a*xa + b*y + e y = -b*xa + a*y + f if zufall == 3: x = c*xa + d*y + g y = -d*xa + c*y + h if zufall == 4: x = a*xa + b*y + k y = -b*xa + a*y + l if zufall == 5: x = a*xa - b*y + m y = b*xa + a*y + n xa = x for i in xrange(0,N): zufall = random.randint(0,5) if zufall == 0: x = a*xa - b*y y = b*xa + a*y if zufall == 1: x = c*xa - d*y + a y = d*xa + c*y + b if zufall == 2: x = a*xa + b*y + e y = -b*xa + a*y + f if zufall == 3: x = c*xa + d*y + g y = -d*xa + c*y + h if zufall == 4: x = a*xa + b*y + k y = -b*xa + a*y + l if zufall == 5: x = a*xa - b*y + m y = b*xa + a*y + n xa = x obj.SetPoint(zz, c4d.Vector((Faktor*x-dx/2.0),(Faktor*y+dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((Faktor*x-dx/2.0),(Faktor*y-dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((Faktor*x+dx/2.0),(Faktor*y+dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((Faktor*x+dx/2.0),(Faktor*y-dy/2.0),0)) zz=zz+1 obj.SetPolygon(zzz, c4d.CPolygon(zz-1,zz-2,zz-4,zz-3)) zzz=zzz+1 obj.Message(c4d.MSG_UPDATE) return obj def main(): plyobj = CreatePolygonObject() doc.InsertObject(plyobj, None, None, True) c4d.EventAdd() if __name__=='__main__': main()