Curves on Surface (ConS)

This notebook illustrates the ConS concept. A range 3D B-spline surface is defined, and a 2D domain curve is mapped onto it. The surface has control net dd; the 2D curve has control polygon cc.

(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];)


nu=2;  (* u-degree *)
llu=5; (* u-domain intervals *)
knotu=Join[Table[0,{i,0,nu}],Table[i/llu,{i,1,llu-1}],Table[1,{i,0,nu}]]//N;

nv=2;  (*v-degree *)
llv=5; (* domain intervals *)
knotv=Join[Table[0,{i,0,nv}],Table[i/llv,{i,1,llv-1}],Table[1,{i,0,nv}]]//N;

dd=Table[{u^1.2,v,Sin[1.5u] -0.2(v-0.5)^2},{u,0,llu+nu-1,1},{v,0,llv+nv-1,1}]//N;
dsurf[u_,v_]:=Sum[Sum[BSplineBasis[{nu,knotu},i,u]*BSplineBasis[{nv,knotv},j,v]*dd[[i+1,j+1]],{i,0,nu+llu-1}],{j,0,nv+llv-1}];


n=3;  (* curve degree *)
ll=15; (* curve domain intervals *)
knot=Join[Table[0,{i,0,n}],Table[i/ll,{i,1,ll-1}],Table[1,{i,0,n}]]//N;

cc=Table[{0.03i*Sin[i]+0.6,0.03i*Cos[i]+0.65},{i,0,ll+n-1}];
curve[t_]:=Sum[BSplineBasis[{n,knot},i,t]*cc[[i+1]],{i,0,n+ll-1}];
cplot=ParametricPlot[curve[t],{t,knot[[1]],knot[[2n+ll+1]]},PlotStyle->{Thick,Green},Axes->False]

cons[t_]:=Sum[
Sum[
BSplineBasis[{nu,knotu},i,curve[t][[1]] ]
*BSplineBasis[{nv,knotv},j,curve[t][[2]]]*
dd[[i+1,j+1]] ,
{i,0,nu+llu-1}],{j,0,nv+llv-1}
];
dsurfplot=ParametricPlot3D[dsurf[u,v],{u,knotu[[1]],knotu[[2nu+llu+1]]},{v,knotv[[1]],knotu[[2nv+llv+1]]},Mesh->None,Axes->False,Boxed->False];
(*dd=Table[{t,Sqrt[t]+0.1RandomReal[],0.1t^2},{t,0,ll+n-1,1}]//N;
dd={{0,0,0},{1,0,0},{1,1,0},{1,0,0},{2,0,1}}//N;*)
consplot=ParametricPlot3D[cons[t],{t,knot[[1]],knot[[2n+ll+1]]},PlotStyle->{Thickness[0.01],Green},Axes->False];

Show[dsurfplot,consplot]