*************ESEMPI DEL PARAGRAFO 7***************** **********Esempio1 import rhinoscriptsyntax as rs numeri =[1,2,3,4,5,6,7,8,9,10] for n in numeri: if n % 5 == 0: rs.AddPoint([10*n,10*n,0]) elif n % 3 == 0: rs.AddPoint([-10*n,-10*n,0]) else: rs.AddPoint([10*n,-10*n,0]) **********Esempio2 import rhinoscriptsyntax as rs for n in range(-10,10): rs.AddSphere([3*n,n**2,0],2) **********Esempio3 import rhinoscriptsyntax as rs start=rs.GetPoint("Inizio linea") if start: end=rs.GetPoint("Fine linea") if end: rs.AddLine(start,end) rs.AddSphere(start,5) rs.AddSphere(end,10) *************ESEMPI DEL PARAGRAFO 9***************** **********Esempio1 import rhinoscriptsyntax as rs def disegnaLineaTraCurve(Curva1,Curva2,numDivs): Listapti1=rs.DivideCurve(Curva1,numDivs,True,True) Listapti2=rs.DivideCurve(Curva2,numDivs,True,True) count=0 for i in Listapti1: rs.AddLine(Listapti1[count],Listapti2[count]) count+=1 PrimaCurva=rs.GetObject("Scegli la prima curva",4) SecondaCurva=rs.GetObject("Scegli la seconda curva",4) divs=int(raw_input("Quante divisioni?")) ogg1=disegnaLineaTraCurve(PrimaCurva,SecondaCurva,divs) **********Esempio2 import rhinoscriptsyntax as rs rs.EnableRedraw(False) def disegnaLineaTraCurve(Curva1,Curva2,numDivs): Listapti1=rs.DivideCurve(Curva1,numDivs,True,True) Listapti2=rs.DivideCurve(Curva2,numDivs,True,True) count=0 for i in Listapti1: rs.AddLine(Listapti1[count],Listapti2[count]) count+=1 PrimaCurva=rs.GetObject("Scegli la prima curva",4) SecondaCurva=rs.GetObject("Scegli la seconda curva",4) divs=int(raw_input("Quante divisioni?")) ogg1=disegnaLineaTraCurve(PrimaCurva,SecondaCurva,divs) rs.EnableRedraw(True) **********Esempio3 ENNAGONO DI CIAMBELLE import rhinoscriptsyntax as rs circolo=rs.AddCircle([0,0,0],50) ListaPti=rs.DivideCurve(circolo,9,False,True) rs.DeleteObject(circolo) rs.AddSphere([0,0,0],5) count=-1 for i in ListaPti: rs.AddLine(ListaPti[count],ListaPti[count+1]) rs.AddLine(ListaPti[count],[0,0,0]) rs.AddTorus(ListaPti[count],5,2) count += 1 **********Esempio4 CARDIOIDE import rhinoscriptsyntax as rs import math def draw_parametric_curve(function, param_range, num_points = 20): points = [] for i in range(num_points): t = param_range[0] + (param_range[1] - \ param_range[0]) * float(i)/float(num_points - 1) points.append(function(t)) rs.AddInterpCurve(points) def miaCurva(t): return [10*(1-2*math.cos(t)+math.cos(2*t)), 10*(2*math.sin(t)-math.sin(2*t)),0] draw_parametric_curve(miaCurva, (0, 2*math.pi)) **********Esempio5 SPIRALE SU SFERA import rhinoscriptsyntax as rs import math r=10 p=0.2 rs.AddSphere((0,0,0),r) def draw_parametric_curve(function, param_range, num_points = 1000): points = [] for i in range(num_points): t = param_range[0] + (param_range[1] - param_range[0]) * \ float(i)/float(num_points - 1) points.append(function(t)) rs.AddInterpCurve(points) def spirale_su_sfera(t): return [r*math.cos(t)/math.sqrt(1+p*p*t*t), r*math.sin(t)/math.sqrt(1+p*p*t*t),-r*p*t/math.sqrt(1+p*p*t*t)] draw_parametric_curve(spirale_su_sfera, (-50,50)) **********Esempio6 TETRAEDRO import rhinoscriptsyntax as rs import math C0=math.sqrt(2)/4 V0 = ( C0, -C0, C0) V1 = ( C0, C0, -C0) V2 = (-C0, C0, C0) V3 = (-C0, -C0, -C0) rs.AddPolyline([V0,V1,V2,V0]) rs.AddPolyline([V1,V0,V3,V1]) rs.AddPolyline([V2,V3,V0,V2]) rs.AddPolyline([V3,V2,V1,V3]) **********Esempio7 GRANDE DODECAEDRO import rhinoscriptsyntax as rs import math C0=(1+math.sqrt(5))/4 V0 = ( 0.5, 0.0, C0) V1 = ( 0.5, 0.0, -C0) V2 = (-0.5, 0.0, C0) V3 = (-0.5, 0.0, -C0) V4 = ( C0, 0.5, 0.0) V5 = ( C0, -0.5, 0.0) V6 = ( -C0, 0.5, 0.0) V7 = ( -C0, -0.5, 0.0) V8 = ( 0.0, C0, 0.5) V9 = ( 0.0, C0, -0.5) V10 = ( 0.0, -C0, 0.5) V11 = ( 0.0, -C0, -0.5) """ rs.AddPoint(V0) rs.AddPoint(V1) rs.AddPoint(V2) rs.AddPoint(V3) rs.AddPoint(V4) rs.AddPoint(V5) rs.AddPoint(V6) rs.AddPoint(V7) rs.AddPoint(V8) rs.AddPoint(V9) rs.AddPoint(V10) rs.AddPoint(V11) """ rs.AddPolyline([V0,V2,V7,V11,V5,V0]) rs.AddPolyline([V0,V5,V1,V9,V8,V0]) rs.AddPolyline([V0,V8,V6,V7,V10,V0]) rs.AddPolyline([V1,V3,V6,V8,V4,V1]) rs.AddPolyline([V1,V4,V0,V10,V11,V1]) rs.AddPolyline([V1,V11,V7,V6,V9,V1]) rs.AddPolyline([V2,V0,V4,V9,V6,V2]) rs.AddPolyline([V2,V6,V3,V11,V10,V2]) rs.AddPolyline([V2,V10,V5,V4,V8,V2]) rs.AddPolyline([V3,V1,V5,V10,V7,V3]) rs.AddPolyline([V3,V7,V2,V8,V9,V3]) rs.AddPolyline([V3,V9,V4,V5,V11,V3]) **********Esempio8 MEDIO ICOSAEDRO TRIAMBICO import rhinoscriptsyntax as rs import math C0 = (3 - math.sqrt(5)) / 2 C1 = (math.sqrt(5) - 1) / 2 C2 = (1 + math.sqrt(5)) / 2 C3 = (3 + math.sqrt(5)) / 2 V0 = ( C2, 0.0, C3) V1 = ( C2, 0.0, -C3) V2 = (-C2, 0.0, C3) V3 = (-C2, 0.0, -C3) V4 = ( C3, C2, 0.0) V5 = ( C3, -C2, 0.0) V6 = (-C3, C2, 0.0) V7 = (-C3, -C2, 0.0) V8 = (0.0, C3, C2) V9 = (0.0, C3, -C2) V10 = (0.0, -C3, C2) V11 = (0.0, -C3, -C2) V12 = ( C0, 0.0, C1) V13 = ( C0, 0.0, -C1) V14 = (-C0, 0.0, C1) V15 = (-C0, 0.0, -C1) V16 = ( C1, C0, 0.0) V17 = ( C1, -C0, 0.0) V18 = (-C1, C0, 0.0) V19 = (-C1, -C0, 0.0) V20 = (0.0, C1, C0) V21 = (0.0, C1, -C0) V22 = (0.0, -C1, C0) V23 = (0.0, -C1, -C0) rs.AddPolyline([V0,V14,V6,V19,V11,V22,V0]) rs.AddPolyline([V0,V22,V7,V23,V1,V17,V0]) rs.AddPolyline([V0,V17,V11,V13,V9,V16,V0]) rs.AddPolyline([V0,V16,V1,V21,V6,V20,V0]) rs.AddPolyline([V0,V20,V9,V18,V7,V14,V0]) rs.AddPolyline([V3,V13,V4,V17,V10,V23,V3]) rs.AddPolyline([V3,V23,V5,V22,V2,V19,V3]) rs.AddPolyline([V3,V19,V10,V14,V8,V18,V3]) rs.AddPolyline([V3,V18,V2,V20,V4,V21,V3]) rs.AddPolyline([V3,V21,V8,V16,V5,V13,V3]) rs.AddPolyline([V12,V2,V22,V11,V17,V4,V12]) rs.AddPolyline([V12,V4,V20,V6,V14,V10,V12]) rs.AddPolyline([V12,V10,V17,V1,V16,V8,V12]) rs.AddPolyline([V12,V8,V14,V7,V22,V5,V12]) rs.AddPolyline([V12,V5,V16,V9,V20,V2,V12]) rs.AddPolyline([V15,V1,V23,V10,V19,V6,V15]) rs.AddPolyline([V15,V6,V21,V4,V13,V11,V15]) rs.AddPolyline([V15,V11,V19,V2,V18,V9,V15]) rs.AddPolyline([V15,V9,V13,V5,V23,V7,V15]) rs.AddPolyline([V15,V7,V18,V8,V21,V1,V15]) *************ESEMPI DEL PARAGRAFO 10***************** **********Esempio1 NASTRO DI MOEBIUS import rhinoscriptsyntax as rhino import math def draw_parametric_surface(function, param_range_u, param_range_v, \ num_points_u = 32, num_points_v = 32): points = [] for i in range(num_points_u): u = param_range_u[0] + (param_range_u[1] - param_range_u[0]) * \ float(i)/float(num_points_u - 1) for j in range(num_points_v): v = param_range_v[0] + (param_range_v[1] - param_range_v[0]) * \ float(j)/float(num_points_v - 1) points.append( function(u,v) ) rhino.AddSrfPtGrid((num_points_u, num_points_v), points) def superf_Prova(u,v): return [(1+(v/2)*math.cos(u/2))*math.cos(u),(1+(v/2)*math.cos(u/2))*\ math.sin(u),(v/2)*math.sin(u/2)] draw_parametric_surface(superf_Prova, (0,2*math.pi), (-1,1)) **********Esempio2 PARABOLOIDE IPERBOLICO import rhinoscriptsyntax as rhino import math def draw_parametric_surface(function, param_range_u, param_range_v, \ num_points_u = 32, num_points_v = 32): points = [] for i in range(num_points_u): u = param_range_u[0] + (param_range_u[1] - param_range_u[0]) * \ float(i)/float(num_points_u - 1) for j in range(num_points_v): v = param_range_v[0] + (param_range_v[1] - param_range_v[0]) * \ float(j)/float(num_points_v - 1) points.append( function(u,v) ) rhino.AddSrfPtGrid((num_points_u, num_points_v), points) def superf_Prova(u,v): return [u,v,u**2/3-v**2/5] draw_parametric_surface(superf_Prova, (-5,5), (-5,5)) **********Esempio3 SUPERFICI DI RICHMOND import rhinoscriptsyntax as rhino import math n=int(raw_input("Ordine (1<=n<=5, per i migliori risultati)")) def draw_parametric_surface(function, param_range_u, param_range_v, \ num_points_u = 100, num_points_v = 100): points = [] for i in range(num_points_u): u = param_range_u[0] + (param_range_u[1] - param_range_u[0]) * \ float(i)/float(num_points_u - 1) for j in range(num_points_v): v = param_range_v[0] + (param_range_v[1] - param_range_v[0]) * \ float(j)/float(num_points_v - 1) points.append( function(u,v) ) rhino.AddSrfPtGrid((num_points_u, num_points_v), points) def superf_Prova(r,t): return [-math.cos(t)/r-r**(2*n+1)/(2*n+1)* math.cos((2*n+1)*t), math.sin(t)/r+r**(2*n+1)/(2*n+1)*math.sin((2*n+1)*t), 2*r**n/n* math.cos(n*t)] draw_parametric_surface(superf_Prova, (0.5,1.21), (0,2*math.pi))