nuvola=ReadList["/Users/falco/Desktop/didattica/curve e superfici 2013bis/disegni.xyz",Number,RecordLists->True];

nuvola[[1]]

Length[nuvola]

RandomChoice[nuvola,10]

nuvola1=Map[Drop[#,-3]&,nuvola];

nuvola1[[1]]

Length[nuvola1]

RandomChoice[nuvola1,5]

Graphics3D[Point[nuvola1],Axes->True]

Length[nuvola1]

Map[Min,Transpose[nuvola1]]

Map[Max,Transpose[nuvola1]]

Graphics3D[Point[nuvola1],Axes->True]

nuvola2=Select[nuvola1,#[[3]]<3&];

Length[nuvola2]

mat=RotationMatrix[{{1,0,0},{0,0,1}}]

Map[mat.#&,nuvola2]

Graphics3D[{PointSize[.001],Point[Map[mat.#&,nuvola2]]},Axes->True]

Graphics3D[{PointSize[.001],Point[nuvola2]},Axes->True]

bar=Map[Mean,Transpose[nuvola2]]

Map[Min,Transpose[nuvola2]]

Map[Max,Transpose[nuvola2]]

dist[{x0_,y0_,z0_},{a_,b_,c_,d_}]:=Abs[a*x0+b*y0+c*z0+d]/Sqrt[a^2+b^2+c^2]

(* bar+(u,0,v) coincide con y-y_bar==0 quindi con i 4 coefficienti (0,1,0,-y_bar) che individuano il piano di equazione cartesiana
a*x+b*y+c*z+d==0 *)

sel=Select[nuvola2,dist[#,{0,1,0,-bar[[2]]}]<0.01&];

bar[[2]]

Show[{Graphics[{PointSize[.001],Red,Point[Map[Drop[#,{2}]&,sel]]},Axes->True]}]

Take[sel,-10]

Show[{Graphics3D[{PointSize[.001],Red,Point[sel]},Axes->True]}]

Show[{Graphics3D[{PointSize[.001],Point[nuvola2],Red,Point[sel]},Axes->True],ParametricPlot3D[bar+{u,0,v},{u,-1,1},{v,-2,2},Mesh->None]}]

Show[{Graphics3D[{PointSize[.001],Point[nuvola2]},Axes->True],ParametricPlot3D[bar+{u,0,v},{u,-1,1},{v,-2,2},Mesh->None]}]

Manipulate[Graphics3D[{PointSize[.001],Point[Select[nuvola1,zmin<#[[3]]<zmax&]]},Axes->True,ImageSize->600],{{zmin,1.7},-1,11},{{zmax,2.1},-1,11}]

cupola=Select[nuvola1,1.66<#[[3]]<2.09&];

Graphics3D[{PointSize[.001],Point[cupola]},Axes->True,ImageSize->600]

cupolasez=Select[nuvola1,And[1.66<#[[3]]<2.09,#[[2]]>-.1]&];

Graphics3D[{PointSize[.001],Point[cupolasez]},Axes->True,ImageSize->800]

Show[{ParametricPlot3D[{2Cos[v]Cos[u],Cos[v]Sin[u],Sin[v]},{u,0,2Pi},{v,0,Pi/2},Mesh->None],ParametricPlot3D[Table[{2Cos[v]Cos[u],Cos[v]Sin[u],Sin[v]},{v,0,Pi/2,Pi/8}],{u,0,2Pi},PlotStyle->{Red,Thick}],ParametricPlot3D[Table[{2Cos[v]Cos[u],Cos[v]Sin[u],Sin[v]},{u,0,2Pi,Pi/8}],{v,0,Pi/2},PlotStyle->{Red,Thick}]},ImageSize->400]

sfera[u_,v_]:={Cos[v]Cos[u],Cos[v]Sin[u],Sin[v]}

Show[{
ParametricPlot3D[sfera[u,v],{u,0,2Pi},{v,0,Pi/2},Mesh->None],ParametricPlot3D[Table[sfera[u,v]/.v->vk,{vk,0,Pi/2,Pi/6}],{u,0,2Pi},PlotStyle->{Red,Thick}],
ParametricPlot3D[Table[sfera[u,v]/.u->uk,{uk,0,2Pi,Pi/6}],{v,0,Pi/2},PlotStyle->{Red,Thick}]
}]

Manipulate[Show[{Graphics3D[{PointSize[.001],Point[Select[nuvola1,zmin<#[[3]]<zmax&]]},Axes->True,ImageSize->600],ParametricPlot3D[]}],{{zmin,1.7},-1,11},{{zmax,2.1},-1,11}]