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

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

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

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

ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ViewPoint->{-0.241, -1.462, 3.042}]

elicoide[u_,v_]:={2v*Cos[u],2v*Sin[u],u}

ParametricPlot3D[elicoide[u,v]//Evaluate,{u,0,4Pi},{v,-1,1},ViewPoint->{1.228, -2.776, 1.495}]

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

pianotangente[x_][u0_,v0_][t_,s_]:=x[u0,v0]+D[x[uu0,vv0],uu0]*t+D[x[uu0,vv0],vv0]*t /. {uu0->u0,vv0->v0}

ee[x_][u_,v_]:=Simplify[D[x[uu,vv],uu].D[x[uu,vv],uu]]/.{uu->u,vv->v}

ff[x_][u_,v_]:=Simplify[D[x[uu,vv],uu].D[x[uu,vv],vv]]/.{uu->u,vv->v}

gg[x_][u_,v_]:=Simplify[D[x[uu,vv],vv].D[x[uu,vv],vv]]/.{uu->u,vv->v}

pff[x_][u_,v_]:={{ee[x][uu,vv],ff[x][uu,vv]},{ff[x][uu,vv],gg[x][uu,vv]}}/.{uu->u,vv->v}
(* questa e' la forma matriciale della prima forma fondamentale*)

pff[catenoide][u,v]//MatrixForm

pff[elicoide][u,v]//MatrixForm

pff[sfera1][u,v]//MatrixForm

eee[x_][u_,v_]:=Simplify[Det[{D[x[uu,vv],uu,uu],D[x[uu,vv],uu],D[x[uu,vv],vv]}]/Sqrt[Det[pff[x][uu,vv]]]]/.{uu->u,vv->v}

fff[x_][u_,v_]:=Simplify[Det[{D[x[uu,vv],uu,vv],D[x[uu,vv],uu],D[x[uu,vv],vv]}]/Sqrt[Det[pff[x][uu,vv]]]]/.{uu->u,vv->v}

ggg[x_][u_,v_]:=Simplify[Det[{D[x[uu,vv],vv,vv],D[x[uu,vv],uu],D[x[uu,vv],vv]}]/Sqrt[Det[pff[x][uu,vv]]]]/.{uu->u,vv->v}

sff[x_][u_,v_]:={{eee[x][uu,vv],fff[x][uu,vv]},{fff[x][uu,vv],ggg[x][uu,vv]}}/.{uu->u,vv->v}

sff[catenoide][u,v]//MatrixForm//PowerExpand

sff[elicoide][u,v]//MatrixForm//PowerExpand

sff[sfera1][u,v]//MatrixForm//PowerExpand

cgauss[x_][u_,v_]:=Simplify[Det[sff[x][uu,vv].Inverse[pff[x][uu,vv]]]]/.{uu->u,vv->v}

cgauss[catenoide][u,v]//MatrixForm

ParametricPlot3D[sfera1[u,v], {u,0,2Pi}, {v,-Pi/2, Pi/2}]

cgauss[elicoide][u,v]//MatrixForm

cgauss[sfera1][u,v]//MatrixForm

cmedia[x_][u_,v_]:=Simplify[-Tr[sff[x][uu,vv].Inverse[pff[x][uu,vv]]]/2]/.{uu->u,vv->v}

cmedia[catenoide][u,v]//MatrixForm

cmedia[elicoide][u,v]//MatrixForm

cmedia[sfera1][u,v]//MatrixForm //PowerExpand

Plot3D[cmedia[catenoide][u,v]//Evaluate,{u,0,2 Pi},{v,-1.5,1.5},PlotPoints->{50,50}]

Plot3D[cmedia[sfera1][u,v],{u,0,Pi},{v,-Pi/2,Pi/2}]

Manipulate[GraphicsRow[{Show[{ParametricPlot3D[sds[u,v], {u,-1,1}, {v,-1,1}, PlotStyle->Opacity[0.5], Mesh -> None], Graphics3D[{Red,PointSize[.04], Point[sds[h,k]]}]}], Show[{Plot3D[cmedia[sds][u,v],{u,-1,1},{v,-1,1}, Mesh -> None],Graphics3D[{Red,PointSize[.04], Point[{h,k,cmedia[sds][h,k]}]}]}]}],{h,-1,1}, {k,-1,1}]

Manipulate[GraphicsRow[{Show[{ParametricPlot3D[sds[u,v], {u,-1,1}, {v,-1,1}, PlotStyle->Opacity[0.5], Mesh -> None], Graphics3D[{Red,PointSize[.04], Point[sds[h,k]]}]}], Show[{Plot3D[cgauss[sds][u,v],{u,-1,1},{v,-1,1}, Mesh -> None],Graphics3D[{Red,PointSize[.04], Point[{h,k,cgauss[sds][h,k]}]}]}]}],{h,-1,1}, {k,-1,1}]

GraphicsRow[{ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ColorFunction->Function[{x,y,z,u,v},Hue[.3*cmedia[catenoide][u,v]]],ColorFunctionScaling->False], ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ColorFunction->Function[{x,y,z,u,v},Hue[cgauss[catenoide][u,v]]],ColorFunctionScaling->False]}]

ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ColorFunction->Function[{x,y,z,u,v},Hue[cmedia[catenoide][u,v]]],ColorFunctionScaling->False]

ParametricPlot3D[sfera1[u,v],{u,0,2Pi},{v,-Pi/2,Pi/2},ColorFunction->Function[{x,y,z,u,v},Hue[.3*cmedia[sfera1][u,v]]],ColorFunctionScaling-> False]

colorisfera[u_,v_] := If[cmedia[sfera1][u,v]<0, Red, Green]

ParametricPlot3D[sfera1[u,v],{u,0,2Pi},{v,-Pi/2,Pi/2},ColorFunction->Function[{x,y,z,u,v},colorisfera[u,v]],ColorFunctionScaling-> False]

coloricatenoidegauss[u_, v_] := If[cgauss[catenoide][u,v]<-.5, Red, Green]


ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ColorFunction->Function[{x,y,z,u,v},coloricatenoidegauss[u,v]],ColorFunctionScaling->False]

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

coloritorettomedia[u_,v_] := If[cmedia[toretto][u,v]<0, Red, Green]
coloritorettogauss[u_,v_] := If[cgauss[toretto][u,v]<0, Red, Green]

ParametricPlot3D[toretto[u,v],{u,0,2Pi},{v,-Pi/2,3Pi/2},ColorFunction->Function[{x,y,z,u,v},coloritorettogauss[u,v]],ColorFunctionScaling-> False]

GraphicsRow[{ParametricPlot3D[toretto[u,v],{u,0,2Pi},{v,-Pi/2,3Pi/2},ColorFunction->Function[{x,y,z,u,v},coloritorettogauss[u,v]],ColorFunctionScaling-> False]ParametricPlot3D[toretto[u,v],{u,0,2Pi},{v,-Pi/2,3Pi/2},ColorFunction->Function[{x,y,z,u,v},coloritorettomedia[u,v]],ColorFunctionScaling-> False]}]

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

ParametricPlot3D[enneper[u,v], {u, -2,2}, {v, -2, 2}, PlotRange -> {{-10,10},{-10,10},{-10,10}}]

cmedia[enneper][u,v]

cgauss[enneper][u,v]

ParametricPlot3D[enneper[u,v],{u,-2,2},{v,-2,2},PlotRange -> {{-10,10},{-10,10},{-10,10}},ColorFunction->Function[{x,y,z,u,v},Hue[cgauss[enneper][u,v]]],ColorFunctionScaling-> False]

ParametricPlot3D[catenoide[u,v],{u,0,2Pi},{v,-1.5,1.5},ColorFunction->Function[{x,y,z,u,v},Hue[.6*cgauss[catenoide][u,v]]],ColorFunctionScaling->False]