##################################### ### DM2_w24 # AGruber@tugraz.at ### ### hu_02_setup # alice_and_bob ### ##################################### ############################## import rhinoscriptsyntax as rs import random ############################## rs.UnitSystem(4) rs.ShowGrid(view=None, show=0) rs.ShowGridAxes(view=None, show=1) rs.EnableRedraw(1) rs.ViewDisplayMode(view=None, mode="Ghosted") rs.Command("-printDisplay State=On enter", 0) rs.ShowObjects(rs.AllObjects()) rs.DeleteObjects( rs.AllObjects() ) rs.CurrentLayer("Default") 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) rs.ClearCommandHistory() #______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) rs.AddPoints( coords_A+coords_B ) rs.AddCurve ( coords_A, 1) rs.AddCurve ( coords_B, 1) rs.ZoomExtents() 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]) # rs.Sleep(1000) ##############################here you go: ########################################## ########################################## layNam = "MY_PROJECT" rs.CurrentLayer(rs.AddLayer(layNam)) rs.LayerPrintColor(layNam, [200,100,100]) #rs.LayerVisible("MY_SETUP", 0) rs.ZoomExtents() rs.Command("-printDisplay State=Off enter", 0) rs.CurrentLayer("Default") """ ############################# ##########################here you go a = [300, 40, 50] b = [150, 90, 300] c = [90, -140 , 95] rs.ObjectColor(rs.AddTextDot("red", a), [200,25,0]) rs.ObjectColor(rs.AddTextDot("green", b), [0,200,25]) rs.ObjectColor(rs.AddTextDot("blue", c), [25,0,200]) num_points = 1000 Mab=[] Mac=[] Mbc=[] for i in range (len(a)): xab = (a[i]+b[i]) //2 xac = (a[i]+c[i]) //2 xbc = (b[i]+c[i]) //2 Mab.append (xab) Mac.append (xac) Mbc.append (xbc) for i in range(num_points): xa = a[0]+random.uniform (-32,60) ya = a[1]+random.uniform (-2,60) za = a[2]+random.uniform (-4,60) xb = b[0]+random.uniform (-32,60) yb = b[1]+random.uniform (-2,50) zb = b[2]+random.uniform (-2,50) xc = c[0]+random.uniform (-32,60) yc = c[1]+random.uniform (-2,50) zc = c[2]+random.uniform (-2,50) colora = (random.randint(0, 225), random.randint(0, 25), 0 ) colorb = (0,random.randint(0, 255), random.randint(0, 25) ) colorc = (random.randint(0, 25),0, random.randint(0, 225) ) rs.ObjectColor(rs.AddTextDot("", [xa,ya,za]),colora) rs.ObjectColor(rs.AddTextDot("", [xb,yb,zb]),colorb) rs.ObjectColor(rs.AddTextDot("", [xc,yc,zc]),colorc) rs.AddLine ( [xa,ya,za], Mab) rs.AddLine ( Mab, [xb,yb,zb]) rs.AddLine ([xa,ya,za], Mac) rs.AddLine ( Mac, [xc,yc,zc]) rs.AddLine ([xb,yb,zb], Mbc) rs.AddLine ( Mbc, [xc,yc,zc]) ##############################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