""" Golden Dragon 06.02.2022 (c) Juergen Meier (www.3d-meier.de) """ import c4d import random import math # Variablen und Konstanten Titel = 'Golden Dragon' # Name N = 10000000 # Anzahl Punkte Nv = 100 # Anzahl Punkte verwerfen dx = 1.0 # Breite Polygon dy = 1.0 # Hoehe Polygon Faktor = 1000 # Skalierungsfaktor r =((math.sqrt(5) - 1)/2.0)**((math.sqrt(5) - 1)/2.0) # 0.742742944625 A = math.acos((1 + r*r - r**4)/(2*r)) # 0.574105428013 B = math.acos((1 - r*r + r**4)/(2*r*r)) # 0.820060092387 a = r * math.cos(A) # 0.62366525633 b = r * math.sin(A) # 0.40337170183 c = r*r * math.cos(math.pi - B) # -0.37633474367 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,1) if zufall == 0: x = a*xa - b*y y = b*xa + a*y if zufall == 1: x = c*xa - b*y + 1 y = b*xa + c*y xa = x for i in xrange(0,N): zufall = random.randint(0,3) if zufall == 0: x = a*xa - b*y y = b*xa + a*y if zufall == 1: x = c*xa - b*y + 1 y = b*xa + c*y 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()