#DM2 WS24 #Hausuebung 02 #Jonathan Hertling import rhinoscriptsyntax as rs import random rs.EnableRedraw(0) alleObjekte = rs.AllObjects() rs.DeleteObjects(alleObjekte) print alleObjekte #print range(10) #int_liste = range(100) # |-----| # | | # |-----| #Wuerfel (aus Uebung am Fr 11.10.2024): wuerfel_coords = [] print wuerfel_coords for i in range(1500): #print i x=random.uniform(0, 10) y=random.uniform(0, 10) z=random.uniform(0, 10) x = x-30 y = y-30 cor = [x,y,z] rs.AddPoint(cor) rs.ZoomExtents() wuerfel_coords.append(cor) #print "i=",i, coords wuerfel_points = rs.AddPoints(wuerfel_coords) for pnt in wuerfel_points: colo = [239, 43, 45] rs.ObjectColor(pnt, colo) # __ # / \ # \__/ #Kugel kugel_coords = [] print kugel_coords for i in range(1500): x = random.uniform(-5, 5) y = random.uniform(-5, 5) z = random.uniform(-5, 5) if (x**2 + y**2 + z**2) <= 5**2: kugel_coords.append([x, y, z]) kugel_points = rs.AddPoints(kugel_coords) for pnt in kugel_points: colo = [244, 124, 0] rs.ObjectColor(pnt, colo) # | # \ # | # / # | #Linie for i in range(min(len(wuerfel_points), len(kugel_points))): anfang_point = wuerfel_points[i] ende_point = kugel_points[i] rs.AddLine(anfang_point, ende_point)