# -*- coding: utf-8 -*- import rhinoscriptsyntax as rs import math # Alle Objekte in der Szene löschen allobjs = rs.AllObjects() if allobjs: rs.DeleteObjects(allobjs) # Parameter s = 137.508 # Phyllotaxis-Winkel (goldener Winkel in Grad) num_points = 1000 # Anzahl der Punkte base_cube_size = 0.1 # Größe der Würfel z_increment = -0.05 # Z-Schritt pro Punkt scaling_factor = 0.1 # Faktor zur Beeinflussung der Größenänderung pts_list = [] # Punkte und Würfel generieren for n in range(num_points): # Berechnung der Polar-Koordinaten angle = math.radians(n * s) # Winkel in Bogenmaß distance = math.sqrt(n) # Radialer Abstand # Kartesische Koordinaten berechnen x = distance * math.cos(angle) # X-Koordinate y = distance * math.sin(angle) # Y-Koordinate z = n * z_increment # Z-Koordinate steigt proportional zu n # Der letzte Punkt wird auf x = 0, y = 0 und der berechneten z-Höhe gesetzt if n == num_points - 1: x, y = 0, 0 last_point = (x, y, z) print(last_point) pts_list.append([x, y, z]) rs.AddPoint((x, y, z)) # Würfelgröße basierend auf der Z-Koordinate anpassen cube_size = base_cube_size + abs(z) * scaling_factor half_size = cube_size / 2 third_size = cube_size / 3 # Eckpunkte des Würfels definieren corner1 = [x - half_size, y - half_size, z - half_size] corner2 = [x + half_size, y - half_size, z - half_size] corner3 = [x + half_size, y + half_size, z - half_size] corner4 = [x - half_size, y + half_size, z - half_size] corner5 = [x - third_size, y - third_size, z + half_size] corner6 = [x + third_size, y - third_size, z + half_size] corner7 = [x + third_size, y + third_size, z + half_size] corner8 = [x - third_size, y + third_size, z + half_size] box = rs.AddBox([corner1, corner2, corner3, corner4, corner5, corner6, corner7, corner8]) # Kurve durch die Punkte erstellen #rs.AddCurve(pts_list, degree=1) # Linien von Fixpunkt zu jedem Punkt in der Punktliste erzeugen ursprung = pts_list[-1] #for pt in pts_list[:-1]: # rs.AddLine(ursprung, pt) if n > 0 and n < num_points - 1: # Überspringe die letzte Box ursprung = pts_list[-1] current_point = [x, y, z] vector = rs.VectorCreate(current_point, ursprung) # Ebene mit dem Vektor als Normalenrichtung plane = rs.PlaneFromNormal(current_point, vector) # Ursprungsebene für den Würfel world_plane = rs.WorldXYPlane() rs.OrientObject(allobjs, world_plane, plane)