############################## ### DM2_w24 hu_03_setUp ### ### _diag / 2024 10 17 ### ############################## import rhinoscriptsyntax as rs import random, time, sys ### sys.path.append("P:/WWW/bobbycar123") ### add path where "DM_lib.py" can be found !!! import DM_lib as dm ### reload(dm) ############################## rs.UnitSystem(3) rs.ShowGrid(view=None, show=1) rs.ShowGridAxes(view=None, show=1) rs.ViewDisplayMode(view=None, mode="Wireframe") rs.EnableRedraw(0) dm.PointRadius(displayModeX=0, rad=3, styl=1) rs.DeleteObjects(rs.AllObjects()) ###################################### anz = random.choice( range(3**4, 3**5, 5) ) dm.allCoords = dm.setUp_hu_03( anz ) coordsCir = dm.allCoords[0] ### calling def from DM_lib to get *new* set of coords coordsCub = dm.allCoords[1] ### calling def from DM_lib to get *new* set of coords ###################################### randomVec = [random.uniform(-30,30) for i in range(3)] coordsCub = [rs.VectorRotate(cor, randomVec[0], randomVec) for cor in coordsCub] coordsCir = [rs.VectorRotate(cor, randomVec[0], randomVec) for cor in coordsCir] siz = rs.Distance( coordsCub[0], coordsCub[1] ) ### edge length of cubus #dm.textDots( coordsCub ) #rs.AddCurve( coordsCub, 1 ) #rs.AddCurve( coordsCir, 1 ) #dm.textDots( coordsCir ) anz = len(coordsCub) print "*** anz =", anz print "*** siz =", round(siz, 2), "/ edge lenght =", round(siz, 2),"*",int(anz/4),"=", round(siz*anz/4, 2) print "*** **********\n" ######################################################### #Koerper 1 = Kugel1 dm.eA() dm.setUp_hu_03() #dm.setUp_hu_03(150) if 0: #zum auskommentieren, wenn 0 dann geht des darunter nicht allCoords = dm.setUp_hu_03(anzahl=14) #print allCoords[0] rs.AddPoints(allCoords[0]) coordsCir = allCoords[0] cen = dm.pntCentroid(coordsCir) rs.AddCurve( [cen, coordsCir[0]]) rs.AddCurve( allCoords[1], 1) dm.textDots(coordsCir) dm.textDots(allCoords[1]) #### Kreis vec = [2, 0, 0] #rs.AddPoint(vec) anz = 1000 rad = 20.0 center = [random.randint(0,30),10, -20] deltaAngle = 360/anz for i in range(anz): angX = deltaAngle*i print angX vecX = rs.VectorRotate( vec, deltaAngle*i, [random.uniform(-20,20), random.uniform(-20,20), random.uniform(-20,20)]) #(vector, angle_degrees, axis) vecX = rs.VectorScale(vecX, random.uniform(5, rad)) vecX = rs.VectorAdd(vecX, center) rs.AddPoint(vecX) ######################################################### #Koerper 1 = Kugel1 dm.eA() dm.setUp_hu_03() #dm.setUp_hu_03(150) if 0: #zum auskommentieren, wenn 0 dann geht des darunter nicht allCoords = dm.setUp_hu_03(anzahl=14) #print allCoords[0] rs.AddPoints(allCoords[0]) coordsCir = allCoords[0] cen = dm.pntCentroid(coordsCir) rs.AddCurve( [cen, coordsCir[0]]) rs.AddCurve( allCoords[1], 1) dm.textDots(coordsCir) dm.textDots(allCoords[1]) #### Kreis vec = [2, 0, 0] #rs.AddPoint(vec) anz = 2000 rad = 40.0 center = [random.randint(15,60),25, -70] deltaAngle = 360/anz for i in range(anz): angX = deltaAngle*i print angX vecX = rs.VectorRotate( vec, deltaAngle*i, [random.uniform(-20,20), random.uniform(-20,20), random.uniform(-20,20)]) #(vector, angle_degrees, axis) vecX = rs.VectorScale(vecX, random.uniform(5, rad)) vecX = rs.VectorAdd(vecX, center) rs.AddPoint(vecX) ######################################################### #Koerper = Wuerfel coords = [] anzahl = 10 xVal = 15 yVal = 15 zVal = 15 for a in range (anzahl): for b in range (anzahl): for c in range (anzahl): x = a*xVal + random.uniform (1, xVal) +20 y = b*yVal + random.uniform (1, yVal) +20 z = c*zVal + random.uniform (1, zVal) cor = [x,y,z] coords.append(cor) points = rs.AddPoints(coords) rs.ObjectColor(points, [255,23,23]) rs.AddCurve( coords, degree=1) curves = rs.AddCurve( coords, degree=1) rs.ObjectColor(curves, [255,0,0]) if 1: curves = 1000 #anzahl der curves all_points = rs.ObjectsByType(1) if len(all_points) < 2: print("Not enough points to connect.") else: for i in range(curves): pt1 = rs.coerce3dpoint(all_points[random.randint(0, len(all_points) - 1)]) pt2 = rs.coerce3dpoint(all_points[random.randint(0, len(all_points) - 1)]) if pt1 and pt2: rs.AddCurve([pt1, pt2])