#Hausuebung 04# import rhinoscriptsyntax as rs import random, time, sys sys.path.append("P:\WWW\lucysday19\DM2") import DM_lib as dm import math alleObjekte = rs.AllObjects() rs.DeleteObjects(alleObjekte) rs.EnableRedraw(0) ################################################################################ ## Buchruecken anzahlR = 15 xValR = 0.05 yValR = 2.3 zValR = 0.5 coordsR = [] for m in range(anzahlR): for t in range(anzahlR): for o in range(anzahlR): xR = m * xValR + random.uniform(0.01, xValR) + 0.1 yR = t * yValR + random.uniform(0.2, yValR) + 0.0 zR = o * zValR + random.uniform(0.01, zValR) + 10.8 corR = [xR, yR, zR] coordsR.append(corR) points = rs.AddPoints(coordsR) rs.ObjectColor(points, [100, 133, 175]) ##Buchcover oben anzahlCu = 15 xValCu = 1.8 yValCu = 2.3 zValCu = 0.05 coordsCu = [] for k in range(anzahlCu): for r in range(anzahlCu): for h in range(anzahlCu): xCu = k * xValCu + random.uniform(0.1, xValCu) + 0.0 yCu = r * yValCu + random.uniform(0.2, yValCu) + 0.0 zCu = h * zValCu + random.uniform(0.01, zValCu) + 18.3 corCu = [xCu, yCu, zCu] coordsCu.append(corCu) points = rs.AddPoints(coordsCu) rs.ObjectColor(points, [100, 133, 175]) ##Buchcover unten anzahlCo = 15 xValCo = 1.8 yValCo = 2.3 zValCo = 0.05 coordsCo = [] for l in range(anzahlCo): for c in range(anzahlCo): for n in range(anzahlCo): xCo = l * xValCo + random.uniform(0.1, xValCo) + 0.0 yCo = c * yValCo + random.uniform(0.2, yValCo) + 0.0 zCo = n * zValCo + random.uniform(0.01, zValCo) + 10.0 corCo = [xCo, yCo, zCo] coordsCo.append(corCo) points = rs.AddPoints(coordsCo) rs.ObjectColor(points, [100, 133, 175]) ##Buchcover unten verbinden mit Coordnatenursprung ursprung = [0, 0, 0] for point in coordsCo: line = rs.AddLine(point, ursprung) rs.ObjectColor(line, [203, 184, 178]) ##Seitenende anzahlS = 15 xValS = 0.0 yValS = 2.3 zValS = 0.5 coordsS = [] for p in range(anzahlS): for d in range(anzahlS): for b in range(anzahlS): xS = p * xValS + random.uniform(0.01, xValS) + 25.0 yS = d * yValS + random.uniform(0.2, yValS) + 0.0 zS = p * zValS + random.uniform(0.01, zValS) + 10.8 corS = [xS, yS, zS] coordsS.append(corS) points = rs.AddPoints(coordsS) rs.ObjectColor(points, [238, 226, 176]) ##Buchseiten verbinden von Buchruecken und Seitenende for i in range(min(len(coordsR), len(coordsS))): line = rs.AddLine(coordsR[i], coordsS[i]) rs.ObjectColor(line, [238, 226, 176]) ##Apfelkugel anzahl = 1200 radius = 20.0 center = (18, 25, 24) deltaAngle = 360/anzahl vector = [ 1, 0, 0] points1= [] for g in range(anzahl): ang1 = deltaAngle * g #print angX vector1 = rs.VectorRotate(vector, ang1, [random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(-1, 1)]) vector1 = rs.VectorScale(vector1, 5) vector1 = rs.VectorAdd(vector1, center) point = rs.AddPoint(vector1) rs.ObjectColor(point, [158, 51, 51]) # Grundsaetzlich schwarz points.append(point) # Speichern des erstellten Punktes ##Apfelstengel anzahlS = 6 xValS = 0.1 yValS = 0.0 zValS = 0.5 coordsS = [] for p in range(anzahlS): for d in range(anzahlS): for b in range(anzahlS): xS = p * xValS + random.uniform(0.01, xValS) + 18.0 yS = d * yValS + random.uniform(0.2, yValS) + 25.0 zS = p * zValS + random.uniform(0.01, zValS) + 29.0 corS = [xS, yS, zS] coordsS.append(corS) points = rs.AddPoints(coordsS) rs.ObjectColor(points, [141, 111, 100])