##################################### ### DM2_w24 # AGruber@tugraz.at ### ### hu_02_setup # alice_and_bob ### ##################################### ############################## import rhinoscriptsyntax as rs import random, sys #sys.path.append("P:\\WWW\\aeroflot/dm2/") #WIN sys.path.append("/Volumes/app/WWW/aeroflot/dm2/") #macOS #import DM_lib as dm ############################## rs.UnitSystem(4) rs.ShowGrid(view=None, show=0) rs.ShowGridAxes(view=None, show=1) rs.ViewDisplayMode(view=None, mode="Ghosted") rs.Command("-printDisplay State=On enter", 0) rs.ClearCommandHistory() rs.DeleteObjects(rs.AllObjects()) rs.EnableRedraw(1) print "\t ********\**/************" print "\t **********\/entanglement" print "\t my quantum /\***********" print "\t***********/**\********* ver _2024 10 11 08:35\n\n", layNam = "MY_SETUP" rs.CurrentLayer(rs.AddLayer(layNam)) rs.LayerPrintColor(layNam, [100,100,100]) rs.LayerPrintWidth(layNam, 1.0) #______base vectors randi = 100 vecA = [ random.uniform(-randi,randi), random.uniform(-randi,randi), random.uniform(-randi,-randi*1.5) ] vecB = [ random.uniform(-randi,randi), random.uniform(-randi,randi), random.uniform( randi, randi*1.5) ] def myCoords( a=random.uniform(50,300), mov=vecA ): coords = [[0,0,0], [a,0,0], [a,a,0], [0,a,0]] rotXYZ = [ random.uniform(-30,30), random.uniform(-30,30), random.uniform(-30,30) ] for i in range( len(coords) ): coords[i] = rs.VectorAdd(coords[i], mov) coords[i] = rs.VectorRotate(coords[i], 30, rotXYZ) return coords coords_A = myCoords(random.uniform(50,300), vecA) coords_B = myCoords(random.uniform(50,300), vecB) for i,cor in enumerate(coords_A): rs.ObjectColor(rs.AddTextDot(str(i-(i>3)*4), cor), [200,200,0]) for i,cor in enumerate(coords_B): rs.ObjectColor(rs.AddTextDot(str(i-(i>3)*4), cor), [0,200,200]) ##############################here you go: ########################################## ########################################## layNam = "MY_PROJECT" rs.CurrentLayer(rs.AddLayer(layNam)) rs.LayerPrintColor(layNam, [200,100,100]) rs.ZoomExtents() rs.Command("-printDisplay State=Off enter", 0) rs.CurrentLayer("MY_PROJECT") ############################# ##########################here you go def divide_distance(denominator, *points): points_out = list(points) for i in range(len(points_out))[1:]: vector = rs.VectorCreate(points[i-1], points[i]) increment = rs.VectorDivide(vector, denominator) for step in range(denominator)[1:]: location = rs.VectorAdd(points[i], increment*step) #point = rs.AddPoint(location) #print point points_out.insert(i, location) #fehler?! ab i !=0 werden Punkte zu weit vorne einsortiert # 1+ (i-1* denominator)? => 1=>1, 2=>5, 3=>9 # count = 1+i; bei jeder coordinate+1 #print points_out return points_out if 1: step0 =[] for (a,b) in zip(coords_A, coords_B): print( a,b ) step0.append(divide_distance(4, a, b)) #print step0[0] for liste in step0: rs.AddPoints( liste ) if 1: #rs.DeleteObjects(rs.AllObjects()) #print(len(step0)) #print(step0) step1 = zip(*step0) #print(step1[0]) #print(len(step1[0])) allCoords = [] print("step2") for (a,b,c,d) in step1: print (a,b,c,d) points_A = divide_distance(4, a,b ) # points_B = divide_distance(4, c,d) points_B.reverse() # zipup = zip(points_A, points_B) for (a,b) in zipup: coordLists = divide_distance(4, a,b) allCoords.append( coordLists ) #for item in allCoords: # rs.AddPoints(item) coords = [] j=0 for i, coordList in enumerate(allCoords[0:]): rs.AddPoints( coordList ) for i,cor in enumerate(coordList): rs.ObjectColor(rs.AddTextDot(str(i-(i>3)*4), cor), [200,200,0]) #dm.textDots( coordList ) #rs.AddCurve( coordList ) if 1 or i%5==0: for k in range(len(coordList)-1): #rs.AddCurve( coordList ) p0 = coordList[k] p1 = coordList[k+1] #rs.ObjectName( rs.AddLine( p0, p1 ), "lin") #coords.append( coordList[j] ) j += 1 #rs.AddCurve( coords, 1 ) #lins = rs.ObjectsByName("lin") #midPtsZ = [ rs.CurveMidPoint(crv)[2] for crv in lins ] #minZ = min(midPtsZ) #maxZ = max(midPtsZ) #print "min max", minZ, maxZ """ if 0: for crv in lins: zVal = rs.CurveMidPoint(crv)[2] col = dm.reMap( zVal, minZ, maxZ, 100,255) rs.ObjectColor( crv, [col, col, 255-col]) #bBox = rs.BoundingBox( rs.AllObjects() ) #rs.AddBox( bBox ) #coordinates = coords_A[0], coords[1] """ # boundingbox finden, skalieren und random coords fuer spheren finden # Herr Grubers Skript erweitern dass es fuer konvexe Polygone funktioniert # Ueberschnitte finden und farbig verbinden # NEXT # Punkten Namen im dictionary zuordnen. # Eine Seite herausfilten ## wie produziere ich eine weitere Seite des rechtecks? ### move mit der plane normalen, dann rotieren xyz? Was ist das Ergebnis von rotieren xyz? # plane koordinaten finden ## plane normale ## zwei weitere Vektoren in 90 Grad zueinander # von dem Mittelpunkt vektoren ansetzen und mentale Box aufmachen # rnd im Bereich der box ##############################here you end ########################################## ########################################## ###################### #______4_lazy_experts: if 0: import time rs.ZoomExtents() rs.Command("-zoom Factor 0.95 enter", 0) rs.Redraw() from datetime import datetime #print str(datetime.now())[0:19] #print datetime.now().strftime('%a %b / %d.%m.%Y um %Huhr und %Mmin und %Ssec') print "\tdate", print time.ctime(), "==", print time.time(), "seconds since 1 January 1970" if 0: ### capture images to P:\ path = "P:/ue_02/images/" ### if there is no folder like this: check your desktop name = "tst" rs.Command("-viewCaptureToFile Width=480 Height=360 Scale=1.5 TransparentBackground=Yes "+path+name, 0) name = name+"_"+str(int(time.time()))+".jpg" rs.Command("-viewCaptureToFile Width=480 Height=360 Scale=2 DrawGrid=No DrawWorldAxes=No DrawCPlaneAxes=No TransparentBackground=No "+path+name, 0) print path+name