# Revision history [back]

### Plotting families (depending on integer parameter(s)) of curvilinear coordinate and isolevel lines and surfaces, resp. for functional and parametric surfaces, and for 3-variate scalar fields and volume deformations in 3D

To begin with a warning: I am a very experienced mathematician but a complete – 'greenhorn' – beginner in SAGE. I would like to be able to plot in the same 3D plot FAMILIES OF PARAMETRIC CURVES IN 3D (x(i)=x(t,i),y=y(t,i),z=z(t,i)) plotted via e.g. parametric_plot3D DEPENDING ON A NON-NEGATIVE INTEGER PARAMETER i in range(I+1) where the coordinate functions x,y,z are defined as functions of t by me and are not necessarily predefined SAGE functions, and where I can vary the non-negative integer I without varying the code. I would like to do the same for FAMILIES OF FUNCTIONAL SURFACES (z=f(x,y,i), DEPENDING ON A NON-NEGATIVE INTEGER PARAMETER i) using e.g. ParametricSurface, as well as TO DO THE SAME for FAMILIES OF PARAMETRIC SURFACES ( (fx(u,v,i),fy(u,v,i),fz(u,v,i)) ) via using e.g. parametric_plot3D DEPENDING ON A NON-NEGATIVE INTEGER PARAMETER i in range(I+1. I would also like to be able to do the same for FAMILIES OF IMPLICITLY DEFINED SURFACES IN 3D DEPENDING ON A NON-NEGATIVE INTEGER PARAMETER i, using e.g. implicit_plot3d ( (f(x,y,z)-C(i)==0, I in range (I+1)), C being a 1-dimensional array (in general algorithmic language) with entries – real numbers in the range of the values of the real-valued f), with the possibility of custom definition of f, I and C. Examining the SAGE tutorials and reference manuals, I have so far been able to find a model solution of this problem only for planar curves in 2D using plot() and only for SAGE-predefined curves (namely, polynomial curves): http://sage.maa.org/home/pub/140/

sage: lotsa_plots = sum([plot(x^n,(x,0,1),color=rainbow(5)[n]) for n in range(5)]) Already in this simple 2D case, if the SAGE-predefined function x^n in the above example be replaced by a custom-defined function f(x,n) , it is not clear to me (a greenhorn!) how to extend the above instance to plotting together the 2D graphs of f(x,n), color=rainbow(N)[n]) for n in range(N), where one should be able to vary N withouth modifying the SAGE code. I think that providing examples solving the above tasks in the SAGE tutorials/manuals (or developing SAGE in this direction if the tasks are currently SAGE-unsolvable!) is of key importance FOR A GREAT MANY OF THE USERS (OR WANNABE USERS) OF SAGE WHO ARE EXPERIENCED THEORETICIANS BUT ARE NOT EXPERIENCED PROGRAMMERS. To facilitate the eventual answering of these questions, I herewith propose a simple but comprehensive example. IF YOU PROVIDE COMPLETE ANSWERS CONCERNING THIS EXAMPLE, YOU WILL HAVE ANSWERED ALL OF THE ABOVE QUESTIONS TOGETHER. Moreover, your answer would certainly merit to be included among the examples in the next version(s) of the SAGE tutorial[(s) and/or reference manual(s).
Consider the 3D scalar field (argument is a 3D vector, value is a real scalar between 0 and 1) F(x,y,z)=exp(-x^2)((cos(piy))^2)*(1/(1+z^2)), -1<=x,y,z<=1 Design a 3D-plot of F (different from ray tracing a grey-scale colored 3D point cloud and different from constructing and plotting several isosurfaces), namely, by using the Curvilinear coordinates in 3D induced by F:

Consider the positive integers l,m,n and knots

-1==x_0<x_1&lt;...<x_l==1, -1="=y_0&lt;y_1&lt;...&lt;y_m==1," -1="=z_0&lt;x_1&lt;...&lt;x_n==1.&lt;/p">

Plot in 3D:

the x-coordinate lines F(x,y_j,z_k), j in range(m+1), k in range(n+1), rgbcolor=(1,0,0), thickness=3; the y-coordinate lines F(x_i,y,z_k), i in range(l+1), k in range(n+1), rgbcolor=(0,1,0), thickness=3; the z-coordinate lines F(x_i,y_j,z), j in range(m+1), k in range(n+1), rgbcolor=(0,0,1), thickness=3; the (x,y)-coordinate surfaces F(x,y,z_k), k in range(n+1), rgbcolor=(1/2,1/2,0), opacity=0.5; the (y,z)-coordinate surfaces F(x_i,y,z), i in range(l+1), rgbcolor=(0,1/2,1/2), opacity=0.5; the (x,z)-coordinate surfaces F(x,y_j,z), j in range(m+1), rgbcolor=(1/2,0,1/2), opacity=0.5;

in a common plot P (equal to the sum of the plots of the separate coordinate lines and surfaces as described above), and then execute the SAGE command

P.show(viewer='jmol')

where l,m,n can be varied as input WITHOUT otherwise CHANGING THE SAGE CODE of the plotting.

Analogously, of interest is an isolevel/isosurface plot of F, as follows:

Consider the positive integer J and the knots

0==c_0<x_1&lt;...<c_k==1, where="" [0,1]="" is="" the="" range="" of="" values="" taken="" by="" f.<="" p="">

Plot in 3D the isolevel surfaces (isosurfaces)

F(x,y,z)-c_I=0, I in range(K+1), color=rainbow(K)[I] , opacity=0.5

using (A) the default implicit_plot3d method and (B) the 'smooth-triangle' method for Tachyon (the normals are very easy to compute),

then sum the plots into P and execute again

P.show(viewer='jmol')

So far I can only plot and visualize (with my preferences being to use jmol for the latter) single 3D-curves (via parametric_plot3d), single functional surfaces (via ParametricSurface) and single parametric surfaces (via parametric_plot3d), as well as single implicitly defined surfaces (via implicit_plot3d) but so far my efforts to organize loops in i,j,k and I to plot the above-sai 3d-geometric objects in a common plot have failed. Typically, in an algorithmic language one would organize the data about the plotting of a single x-coordinate line in a 2-dimensional array Plinex(j,k) using parametric_plot3d for the design of every entry in the array, and then it should be possible to execute something of the type

P=sum(Plinex(j,k), j in range(m+1), k in range(n+1))

Analogously, in this hypothetical algorithmic language the data about the plotting of a single (x,y)-coordinate surface should be organized in a 1-dimensional array Psurfxy(k) using ParametricSurface for the design of every entry in the array, and then it should be possible to execute something of the type

P=sum(Psurfxy(k), k in range(n+1))

Also analogously, one should be able to organize the data about the plotting of a single isosurface in a 1-dimensional array Pisosurf(I) using implicit_plot3d (in each of the variants A and B considered above, or at least in variant A only) for the design of every entry in the array, and then it should be possible to execute something of the type

P=sum(Pisosurf(I), I in range(K+1))

The only case mentioned in the title which this example does not cover is the case of plotting curvilinear curves and surfaces for a PARAMETRIC VOLUME DEFORMATION (i.e., (x=fx(u,v,w),y=fy(u,v,w),z=fz(u,v,w)) where (u,v,w) belongs to 3-VARIATE parametric domain), but handling this case would be an easy consequence of the case of a scalar field F(x,y,z) considered above.

Unfortunately, being a newbie in SAGE, I do not know how to write all this in SAGE.