""" Appolonian Gasket Logarithmus 11.06.2022 www.3d-meier.de """ import c4d import random import math import cmath # Variablen und Konstanten Titel = 'Appolonian Gasket Logarithmus' # Name N = 1000000 # Anzahl Punkte dx = 0.015 # Breite Polygon dy = 0.015 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor s = math.sqrt(3.0) # Konstante s i = complex(0, 1) # Konstante i def CreatePolygonObject(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(4*N, N) obj.SetName(Titel) # Startwert der Berechnung z = complex(0.50, 0) # Zaeher fuer Punkte setzten zz = 0 # Zaehler fuer Polygone setzten zzz = 0 for i in xrange(0,N): z = 3/(1 + s - z) - (1 + s)/(2 + s) zufall = random.randint(0,12) if zufall == 0: z = complex(-1, s)/(2*z) if zufall == 1: z = complex(-1, -s)/(2*z) za=cmath.log(z) x = za.real y = za.imag obj.SetPoint(zz, c4d.Vector((x-dx/2.0)*Faktor,(y+dy/2.0)*Faktor,0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x-dx/2.0)*Faktor,(y-dy/2.0)*Faktor,0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x+dx/2.0)*Faktor,(y+dy/2.0)*Faktor,0)) zz=zz+1 obj.SetPoint(zz, c4d.Vector((x+dx/2.0)*Faktor,(y-dy/2.0)*Faktor,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()