""" Flowsnake 27.08.2019 www.3d-meier.de """ import c4d import random import math import cmath # Variablen und Konstanten Titel = 'Flowsnake' # Name N = 1000000 # Anzahl Punkte Nv = 10 # Anzahl Punkte verwerfen dx = 1.50 # Breite Polygon dy = 1.50 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor def CreatePolygonObject(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(4*N, N) obj.SetName(Titel) # Startwert der Berechnung z = complex(0.50, 0) # Konstante # a = (cmath.exp(complex(0, 1)*math.atan(math.sqrt(3.0)/5.0)))/math.sqrt(7.0) # a = cmath.exp(complex(0, 1)*math.atan(math.sqrt(3.0)/5.0))/math.sqrt(7.0) a = cmath.exp(complex(0, 1)*math.atan(math.sqrt(3.0)/5.0))/math.sqrt(7.0) # Zähler für Punkte setzten zz = 0 # Zähler für Polygone setzten zzz = 0 for i in xrange(0,Nv): zufall = random.randint(0,6) if zufall == 0: z = a*z if zufall == 1: z = a*z + 1 if zufall == 2: z = a*z + complex(1, math.sqrt(3.0)) if zufall == 3: z = a*z + complex(0, math.sqrt(3.0)) if zufall == 4: z = a*z + complex(0.5, math.sqrt(3.0)/2.0) if zufall == 5: z = a*z + complex(1.5, math.sqrt(3.0)/2.0) if zufall == 6: z = a*z + complex(-0.5, math.sqrt(3.0)/2.0) for i in xrange(0,N): zufall = random.randint(0,6) if zufall == 0: z = a*z if zufall == 1: z = a*z + 1 if zufall == 2: z = a*z + complex(1, math.sqrt(3.0)) if zufall == 3: z = a*z + complex(0, math.sqrt(3.0)) if zufall == 4: z = a*z + complex(0.5, math.sqrt(3.0)/2.0) if zufall == 5: z = a*z + complex(1.5, math.sqrt(3.0)/2.0) if zufall == 6: z = a*z + complex(-0.5, math.sqrt(3.0)/2.0) x = z.real*Faktor y = z.imag*Faktor obj.SetPoint(zz, c4d.Vector((x-dx/2.0),(y+dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x-dx/2.0),(y-dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x+dx/2.0),(y+dy/2.0),0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x+dx/2.0),(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()