""" Spiral Fraktal 5 07.02.2022 (c) Juergen Meier (www.3d-meier.de) """ import c4d import random import math # Variablen und Konstanten Titel = 'Spiral Fraktal 5' # Name N = 10000000 # Anzahl Punkte Nv = 100 # Anzahl Punkte verwerfen dx = 0.50 # Breite Polygon dy = 0.50 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor k = [( 0.3, 0.3, 0, 0, -0.36, 0.7, 0.1), ( 0.9, 0.9, 30, 30, 0.00, 0.0, 0.9)] def CreatePolygonObject(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(4*N, N) obj.SetName(Titel) # Startwert der Berechnung xa = 0.5 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,100) if zufall < 10: x = k[0][0]*math.cos(math.radians(k[0][2]))*xa + k[0][1]*math.sin(math.radians(k[0][3]))*y + k[0][4] y = -k[0][0]*math.sin(math.radians(k[0][2]))*xa + k[0][1]*math.cos(math.radians(k[0][3]))*y + k[0][5] if zufall >= 10: x = k[1][0]*math.cos(math.radians(k[1][2]))*xa + k[1][1]*math.sin(math.radians(k[1][3]))*y + k[1][4] y = -k[1][0]*math.sin(math.radians(k[1][2]))*xa + k[1][1]*math.cos(math.radians(k[1][3]))*y + k[1][5] xa = x for i in xrange(0,N): zufall = random.randint(0,100) if zufall < 10: x = k[0][0]*math.cos(math.radians(k[0][2]))*xa + k[0][1]*math.sin(math.radians(k[0][3]))*y + k[0][4] y = -k[0][0]*math.sin(math.radians(k[0][2]))*xa + k[0][1]*math.cos(math.radians(k[0][3]))*y + k[0][5] if zufall >= 10: x = k[1][0]*math.cos(math.radians(k[1][2]))*xa + k[1][1]*math.sin(math.radians(k[1][3]))*y + k[1][4] y = -k[1][0]*math.sin(math.radians(k[1][2]))*xa + k[1][1]*math.cos(math.radians(k[1][3]))*y + k[1][5] 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()