(* Come disegnare le superfici*)
(* primo metodo Plot3D *)


Plot3D[Cos[x+y^2],{x,-3,3},{y,-2,2}]

(*secondo metodo ParametricPlot3D con il nastro di moebius*)

ParametricPlot3D[{(1+v/2*Cos[1/2*u])*Cos[u],(1+v/2*Cos[1/2*u])*Sin[u],v/2*Sin[u/2]},{u,0,2*Pi},{v,-1,1}]

(* come renderlo piu' bello? *)

ParametricPlot3D[{(1+v/2*Cos[1/2*u])*Cos[u],(1+v/2*Cos[1/2*u])*Sin[u],v/2*Sin[u/2]},{u,0,2*Pi},{v,-1,1}, BoxRatios->{1,1,1}]

ParametricPlot3D[{(1+v/2*Cos[1/2*u])*Cos[u],(1+v/2*Cos[1/2*u])*Sin[u],v/2*Sin[u/2]},{u,0,2*Pi},{v,-1,1}, Mesh->None, BoxRatios->{1,1,1}, Boxed -> False, Axes -> False]

ParametricPlot3D[{(1+v/2*Cos[1/2*u])*Cos[u],(1+v/2*Cos[1/2*u])*Sin[u],v/2*Sin[u/2]},{u,0,2*Pi},{v,-1,1}, Mesh->None, BoxRatios->{1,1,1}, PlotStyle->Directive[Black,Specularity[White,10]],Lighting->"Neutral"]

ParametricPlot3D[{(1+v/2*Cos[1/2*u])*Cos[u],(1+v/2*Cos[1/2*u])*Sin[u],v/2*Sin[u/2]},{u,0,2*Pi},{v,-1,1}, Mesh->None, BoxRatios->{1,1,1}, PlotStyle->Directive[Red,Opacity[.7]]]

toretto[u_, v_]:={Cos[u] (2+Cos[v]),Sin[u] (3+Cos[v]),Sin[v]}



ParametricPlot3D[toretto[u,v], {u, 0, 2Pi}, {v, 0, 2Pi}]

(* terzo metodo ContourPlot *)

ContourPlot3D[x^4+y^4+z^4-(x^2+y^2+z^2)^2+3(x^2+y^2+z^2)==3,{x, -2,2}, {y, -2, 2}, {z, -2, 2}]

ContourPlot3D[x^4+y^4+z^4-(x^2+y^2+z^2)^2+3(x^2+y^2+z^2)==0,{x, -100,100}, {y, -100, 100}, {z, -100, 100},Mesh->None,ContourStyle->Directive[Green,Opacity[0.4],Specularity[White,30]]]

selladiscimmia[u_,v_]:={u,v,u^3-3u*v^2}

paraboloideiperbolico[u_,v_]:={u,v,u*v}

ParametricPlot3D[selladiscimmia[u, v], {u, -1, 1}, {v, -1, 1}]

ParametricPlot3D[paraboloideiperbolico[u, v], {u, -10, 10}, {v, -10, 10},  BoxRatios->{1,1,1}]

Manipulate[ContourPlot3D[x^2+y^2==a+z^2, {x,-2, 2}, {y, -2, 2}, {z, -4, 4}], {a, -1, 1}]

ContourPlot3D[x^2+y^2==z^2, {x,-2, 2}, {y, -2, 2}, {z, -4, 4}]

toro[a_,b_][u_,v_]:={Cos[u] (a+Cos[v]),Sin[u] (b+Cos[v]),Sin[v]}

ParametricPlot3D[toro[3,2][u,v], {u, 0, 2Pi}, {v, 0, 2Pi}]

romans[a_][u_, v_] :={Sin[2u]Cos[v]^2, Sin[u]Sin[2v], Cos[u]Sin[2v]}

ParametricPlot3D[romans[-1][u, v] ,{u, 0,2Pi}, {v, 0, 2Pi}]

(* versore normale *)

unitnormal[x_][u_,v_]:=Block[{xu,xv,N1},
xu=D[x[uu,vv],uu];
xv=D[x[uu,vv],vv];
N1=Cross[xu,xv];
Return[Simplify[N1.N1]^(-1/2)*N1 /. {uu->u,vv->v}];
];

unitnormal[paraboloideiperbolico][u,v]

ParametricPlot3D[{paraboloideiperbolico[u,v],unitnormal[paraboloideiperbolico][u,v]},{u,-1,1},{v,-1,1}]

unitnormal[selladiscimmia][u,v]

ParametricPlot3D[{selladiscimmia[u,v],unitnormal[selladiscimmia][u,v]},{u,-1,1},{v,-1,1}]

pianotangente[x_][u0_,v0_][u_,v_]:=x[u0,v0]+D[x[uu0,vv0],uu0]*u+D[x[uu0,vv0],vv0]*v /. {uu0->u0,vv0->v0}

Show[{
ParametricPlot3D[selladiscimmia[u,v],{u,-1,1},{v,-1,1}],
ParametricPlot3D[pianotangente[selladiscimmia][0,0][u,v],{u,-.4,.4},{v,-.4,.4},Mesh->None]
}]

Show[{
ParametricPlot3D[selladiscimmia[u,v],{u,-1,1},{v,-1,1}],
ParametricPlot3D[pianotangente[selladiscimmia][0,0][u,v],{u,-.4,.4},{v,-.4,.4},Mesh->None]
}]

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

ParametricPlot3D[sfera[u,v], {u, 0, Pi}, {v, -Pi, Pi}]

Show[{
ParametricPlot3D[sfera[u,v],{u,0,Pi},{v,-Pi,Pi}],
ParametricPlot3D[pianotangente[sfera][Pi/7,-Pi/4][u,v],{u,-.4,.4},{v,-.4,.4},Mesh->None]
}]

Show[{ParametricPlot3D[toretto[u,v], {u, 0, 2Pi}, {v, 0, 2Pi}],
ParametricPlot3D[pianotangente[toretto][0,0][u,v],{u,-.4,.4},{v,-.4,.4},Mesh->None]
}]

Show[{ParametricPlot3D[toretto[u,v], {u, 0, 2Pi}, {v, 0, 2Pi}, PlotStyle -> Opacity[.3]],
ParametricPlot3D[pianotangente[toretto][Pi,Pi][u,v],{u,-.8,.8},{v,-.8,.8},Mesh->None]
}]

astell[a_,b_,c_][u_,v_]:={a*Cos[u]Cos[v],b*Sin[u]Cos[v],c*Sin[v]}^3

ParametricPlot3D[astell[1,1,1][u, v], {u, 0, 2Pi}, {v, 0,2Pi}, BoxRatios -> {2,2,1}, PlotRange-> {{-2,2}, {-2,2}}]