#! python 2 ############################## # final.PROJECT: female icons # friendship bracelets wrapped around the Empire State Building ############################## import math import sys ############################## import rhinoscriptsyntax as rs sys.path.append("/Users/anny.more/Documents/studium/5. semester/DM2") #sys.path.append("P:/") #sys.path.append("C:/Users/c4ffrey/Documents/Rhino/") import DM_lib as dm ############################## rs.UnitSystem(4) rs.ShowGrid(None, 0) rs.ShowGridAxes(None, 1) rs.ViewDisplayMode(rs.CurrentView(), "shaded") rs.Command("cplane w t enter", 0) dm.PointRadius(displayModeX=0, rad=3, styl=3) dm.printDisplay(1) rs.EnableRedraw(0) ############################## ######################################################################################### # HELIX ######################################################################################### dm.newEmptyLayer("taylor") helix_color = (150, 50, 100) # Top of the ESB # print rs.GetObject() points = dm.getSurfacePoints('bbf2dcc5-17b4-43a8-95f6-d2a27887e12d') start = None n = 0 for point in points: if point.Z > 0: if start: start = rs.VectorAdd(start, point) else: start = point n += 1 start = rs.VectorDivide(start, n) def create_helix(turns=5, base_radius=50): base_point = [start.X, start.Y, 0] helix_points = [] for i in range(turns * 50): angle = i * (2 * math.pi / 50) threshold = 120 radius = base_radius if i <= threshold else base_radius * (1 - (i - threshold) / (turns * 50 - threshold)) x = base_point[0] + radius * math.cos(angle) y = base_point[1] + radius * math.sin(angle) z = base_point[2] + start.Z * i / (turns * 50) helix_points.append([x, y, z]) helix_curve = rs.AddCurve(helix_points) rs.ObjectColor(helix_curve, helix_color) rs.ObjectPrintWidth(helix_curve, 5) return (helix_curve, helix_points) _, points = create_helix() ######################################################################################### # BEADS ######################################################################################### class Decoration: def __init__(self, main_color, step=2, amount=50, color=(255, 255, 255)): self.main_color = main_color self.step = step self.amount = amount self.color = color def sphere(r, n, c, step=1): for i in range(0, n, step): theta = math.acos(1 - 2 * (i + 0.5) / n) phi = math.pi * (1 + 5 ** 0.5) * i x = r * math.sin(theta) * math.cos(phi) y = r * math.sin(theta) * math.sin(phi) z = r * math.cos(theta) yield rs.AddPoint(rs.VectorAdd(c, [x, y, z])) def decorated_sphere(center, d): for p in sphere(15, 500, center): rs.ObjectColor(p, d.main_color) for p in sphere(16, d.amount, center, d.step): rs.ObjectColor(p, d.color) decorations = [ Decoration((255, 105, 180), 1, 50), #debut tv Decoration((34, 139, 34), 3, 150), #(255, 105, 180)), #rep tv Decoration((0, 150, 139), 4, 300), #ttpd Decoration((205, 133, 63), 5, 500), #midnights Decoration((255, 60, 122), 6, 600), #evermore Decoration((186, 85, 211), 7, 700), #folklore Decoration((255, 105, 180), 2, 200), #lover Decoration((100, 50, 139), 3, 150 ), #reputation Decoration((0, 100, 255), 2, 100 ), #1989 Decoration((255, 160, 122), 1, 100 ), #red Decoration((186, 85, 211), 5, 500 ), #speak now Decoration((255, 160, 122), 3, 300 ), #fearless Decoration((34, 139, 34), 5, 500 )] #debut for i, p in enumerate(range(20, len(points) - 75, 12)): decorated_sphere(points[p], decorations[i])