""" Minkowski Kurve 27.08.2019 www.3d-meier.de """ import c4d import random import math import cmath # Variablen und Konstanten Titel = 'Minkowski Kurve' # Name N = 1000000 # Anzahl Punkte Nv = 100 # Anzahl Punkte verwerfen dx = 1.30 # Breite Polygon dy = 1.30 # 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) # 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,7) if zufall == 0: z = complex(1, 0)*z/4.0 + complex(0, 0)/4.0 if zufall == 1: z = complex(0, 1)*z/4.0 + complex(1, 0)/4.0 if zufall == 2: z = complex(1, 0)*z/4.0 + complex(1, 1)/4.0 if zufall == 3: z = complex(0, -1)*z/4.0 + complex(2, 1)/4.0 if zufall == 4: z = complex(0, -1)*z/4.0 + complex(2, 0)/4.0 if zufall == 5: z = complex(1, 0)*z/4.0 + complex(2, -1)/4.0 if zufall == 6: z = complex(0, 1)*z/4.0 + complex(3, -1)/4.0 if zufall == 7: z = complex(1, 0)*z/4.0 + complex(3, 0)/4.0 for i in xrange(0,N): zufall = random.randint(0,7) if zufall == 0: z = complex(1, 0)*z/4.0 + complex(0, 0)/4.0 if zufall == 1: z = complex(0, 1)*z/4.0 + complex(1, 0)/4.0 if zufall == 2: z = complex(1, 0)*z/4.0 + complex(1, 1)/4.0 if zufall == 3: z = complex(0, -1)*z/4.0 + complex(2, 1)/4.0 if zufall == 4: z = complex(0, -1)*z/4.0 + complex(2, 0)/4.0 if zufall == 5: z = complex(1, 0)*z/4.0 + complex(2, -1)/4.0 if zufall == 6: z = complex(0, 1)*z/4.0 + complex(3, -1)/4.0 if zufall == 7: z = complex(1, 0)*z/4.0 + complex(3, 0)/4.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()