# -*- coding: utf-8 -*- import rhinoscriptsyntax as rs import math import random alleObjekte = rs.AllObjects() rs.DeleteObjects(alleObjekte) def create_sunflower_with_points_and_curves(center, radius, num_petals, height_factor=0.5, stem_height=20, leaf_count=4, stem_radius=0.5): # Liste für Punkte und Kurven points = [] petals_curves = [] golden_angle = math.radians(137.5) angle_shift = 0 for i in range(num_petals): angle = i * golden_angle + angle_shift x = center[0] + radius * math.cos(angle) y = center[1] + radius * math.sin(angle) #kippen z = center[2] + height_factor * math.sin(angle * 2) # Punkt point = rs.AddPoint(x, y, z) points.append(point) if i > 0: line = rs.AddLine(points[i-1], points[i]) petals_curves.append(line) for i in range(num_petals): line = rs.AddLine(points[i], points[(i + 1) % num_petals]) petals_curves.append(line) rs.ObjectColor(line, (255, 255, 0)) # Gelb: RGB(255, 255, 0) # Stängel stem_points = [] for i in range(2): stem_x = center[0] + random.uniform(-stem_radius, stem_radius) # Zufällige leichte Schwankung stem_y = center[1] + random.uniform(-stem_radius, stem_radius) stem_z = center[2] - stem_height + i * stem_height stem_points.append((stem_x, stem_y, stem_z)) stem_curve = rs.AddInterpCurve(stem_points) rs.ObjectColor(stem_curve, (34, 139, 34)) # Grüner Stängel: RGB(34, 139, 34) # Blätter leaves_curves = [] for i in range(leaf_count): # Zufällige Position für Blätter entlang des Stängels t = random.uniform(0.3, 0.7) leaf_pos = (center[0] + random.uniform(-2, 2), center[1] + random.uniform(-2, 2), center[2] - stem_height + t * stem_height) # Blatt leaf_points = [] for j in range(10): leaf_x = leaf_pos[0] + 5 * math.cos(math.radians(j * 36)) leaf_y = leaf_pos[1] + 15 * math.sin(math.radians(j * 36)) leaf_points.append((leaf_x, leaf_y, leaf_pos[2])) leaf_curve = rs.AddInterpCurve(leaf_points) rs.ObjectColor(leaf_curve, (0, 128, 0)) # Grünes Blatt: RGB(0, 128, 0) leaves_curves.append(leaf_curve) return points, petals_curves, stem_curve, leaves_curves # Parameter center = (0, 0, 0) # Zentrum der Sonnenblume radius = 10 # Radius der Blume num_petals = 50 # Anzahl der Blütenblätter height_factor = 0.5 stem_height = 20 leaf_count = 4 stem_radius = 0.5 points, petals_curves, stem_curve, leaves_curves = create_sunflower_with_points_and_curves(center, radius, num_petals, height_factor, stem_height, leaf_count, stem_radius)