""" Appolonian Gasket Varianten 08.06.2022 www.3d-meier.de """ import c4d import random import math import cmath # Variablen und Konstanten Titel = 'Appolonian Gasket' # Name N = 1000000 # Anzahl Punkte dx = 0.003 # Breite Polygon dy = 0.003 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor s = math.sqrt(3.0) # Konstante s i = complex(0, 1) # Konstante i Variante = 0 # Auswahl der Moebius Transformation Moebius = [( 1.0, 0.0, 0.0, 1.0), ( 1.0, -1.0, 1.0, 1.0), ( 1.0, 1.0, 1.0, -1.0), ( 2.0, -1.0, 2.0, 1.0), (-15.0, -1.0, -1.0, 25.0), ( 10.0, -8.0, -2.0, 1.0)] def CreatePolygonObject(): obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject(4*N, N) obj.SetName(Titel) # Startwert der Berechnung z = complex(0.50, 0) # Zaehler fue 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,2) if zufall == 0: z = complex(-1, s)/(2*z) if zufall == 1: z = complex(-1, -s)/(2*z) za = (Moebius[Variante][0]*z + Moebius[Variante][1])/(Moebius[Variante][2]*z + Moebius[Variante][3]) 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()