Function Repository Resource:

SectionParametricPlot3D

Source Notebook

Plot a surface defined parametrically together with various types of sections of the surface

Contributed by: Dennis M Schneider

ResourceFunction["SectionParametricPlot3D"][{fx,fy,fz},{u,umin,umax},{v,vmin,vmax},opts]

plots a 3D surface parametrized by u and v with sections specified by the options "XSection","YSection","ZSection","VSection" and "OSection".

ResourceFunction["SectionParametricPlot3D"][f,u,v,{{gx,gy},},{t,tmin,tmax}]

plots a 3D surface together with the generalized cylinders described parametrically by {{gx,gy},} over {t,tmin,tmax}.

ResourceFunction["SectionParametricPlot3D"][f,u,v,{{gx,gy,gz},},t]

plots the cylinders to the z-value of gz.

Details and Options

Generalized cylinders need not be circular.
Generalized cylinders are defined as in MathWorld.
Generalized cylinders described by two parametric equations are drawn from the base of the bounding box to the top of the box.
Generalized cylinders described by three parametric equations are drawn from the base of the bounding box to the height gz(t).
ResourceFunction["SectionParametricPlot3D"] has the same options as ParametricPlot3D, with the following additions and changes:
"ColorFunctionSection"Automaticspecifies the color function(s) for the section
"ColorFunctionSurface"Automaticspecifies the color function(s) for the surface
"CylinderBase"Automaticdetermines the z-value to which cylinders are projected
"CylinderRange"Automaticdetermines the range of the cylinder
"CylinderStyle"Opacity[0.5]specifies style for the cylinder; it ignores color specifications
"DrawCylinder"Truewhether to draw the cylinder determining parametrically defined sections
"DrawPoint"{}a list of points to be included in the plot
"DrawPointStyle"{{Red,PointSize[Large]}}styles to be applied to the points specified with the option "DrawPoint"
"OSection"{}draws an oblique section determined by functions of the form z=f[x],z=g[y] or z=h[x,y]
"OSectionStyle"{{Red,Tube[.02]}}styles to be applied to the oblique sections
"PlotPointsSection"75specifies how many initial sample points to use in plotting sections
PlotStyleOpacity[0.7]graphics directive for the style for each surface
"SectionStyle"{{Red,Tube[.02]}}styles to be applied to sections defined parametrically by {gx,gy}
"SectionVariables"{}specify independent variables used to define v-sections or o-sections
"Surface"Truewhether to return the surface in the plot
"VSection"{}draws vertical section(s) for a function or list of functions of the form y=f[x] or x=g[y]
"VSectionStyle"{{Red,Tube[.02]}}styles to be applied to the vertical sections
"XSection"{}draws vertical sections parallel to the yz-plane determined by the value or list of values of x
"XSectionStyle"{{Red,Tube[.02]}}styles to be applied to the x-sections
"YSection"{}draws vertical sections parallel to the xz-plane determined by the value or list of values of y
"YSectionStyle"{{Red,Tube[.02]}}styles to be applied to the y-sections
"ZSection"{}draws horizontal sections parallel to the xy-plane determined by the value or list of values of z
"ZSectionStyle"{{Red,Tube[.02]}}styles to be applied to the z-sections
When "DrawPoint" contains points with two coordinates, those points represent (u,v)-coordinates and the point is found by substituting these values into the parametric equations defining the surface. When "DrawPoint" contains points with three coordinates, then the point is given in (x,y,z)-coordinates.

Examples

Basic Examples (1) 

Plot a paraboloid with an elliptical section:

In[1]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2}, {t, 0, 2 \[Pi]}, {r, 0, 1}, {Cos[u]/2, Sin[u], Cos[u]^2/4 + Sin[u]^2}, {u, 0, 2 \[Pi]}]
Out[1]=

Scope (3) 

Plot a surface with all possible plane sections:

In[2]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/40744648-2425-4b7b-b36d-9c14af1e9d85"]
Out[2]=

Plot a surface with both a plane section and a parametrically defined section:

In[3]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "ZSection" -> 1/4]
Out[3]=

Plot two surfaces with their intersection illustrated with two sections:

In[4]:=
ResourceFunction[
 "SectionParametricPlot3D"][{{r Cos[t], r Sin[t], 1 - r^2}, {r Cos[t],
    r Sin[t], r^2 Cos[2 t]}}, {r, 0, 1}, {t, 0, 2 \[Pi]}, "CylinderStyle" -> Opacity[.6], BoxRatios -> Automatic, "XSection" -> {-1/Sqrt[2], 1/Sqrt[2]}, PlotStyle -> {Opacity[.8], Opacity[1]}]
Out[4]=

Define the x-sections by parametrically defined curves:

In[5]:=
ResourceFunction[
 "SectionParametricPlot3D"][{{r Cos[t], r Sin[t], 1 - r^2}, {r Cos[t],
    r Sin[t], r^2 Cos[2 t]}}, {r, 0, 1}, {t, 0, 2 \[Pi]}, {{-1/Sqrt[2], -y, 1/2 - y^2}, {1/Sqrt[2], -y, 1/2 - y^2}}, {y, -1/Sqrt[2], 1/Sqrt[2]}, "CylinderStyle" -> Opacity[.7], BoxRatios -> Automatic, PlotStyle -> {Opacity[.8], Opacity[1]}]
Out[5]=

Illustrate the x-sections without including the cylinder used to define them:

In[6]:=
ResourceFunction[
 "SectionParametricPlot3D"][{{r Cos[t], r Sin[t], 1 - r^2}, {r Cos[t],
    r Sin[t], r^2 Cos[2 t]}}, {r, 0, 1}, {t, 0, 2 \[Pi]}, {{-1/Sqrt[2], -y, 1/2 - y^2}, {1/Sqrt[2], -y, 1/2 - y^2}}, {y, -1/Sqrt[2], 1/Sqrt[2]}, "DrawCylinder" -> False, BoxRatios -> Automatic, PlotStyle -> {Opacity[.8], Opacity[1]}]
Out[6]=

Options (30) 

ColorFunctionSection (2) 

Set a color function for the sections:

In[7]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {{Cos[t], Sin[t], Cos[2 t]}, {1/2 Cos[t], 1/2 Sin[t], 1/4 Cos[2 t]}}, {t, 0, 2 \[Pi]}, "ColorFunctionSection" -> Function[{x, y, z, t}, GrayLevel[t]], BoxRatios -> Automatic]
Out[7]=

Set a different style for each section:

In[8]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {{Cos[t], Sin[t], Cos[2 t]}, {1/2 Cos[t], 1/2 Sin[t], 1/4 Cos[2 t]}}, {t, 0, 2 \[Pi]}, "ColorFunctionSection" -> {Function[{x, y, z, t}, Hue[t/2]], Function[{x, y, z, t}, Hue[t]]}, BoxRatios -> Automatic]
Out[8]=

ColorFunctionSurface (2) 

Set a style for the surface:

In[9]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {{Cos[t], Sin[t], Cos[2 t]}, {1/2 Cos[t], 1/2 Sin[t], 1/4 Cos[2 t]}}, {t, 0, 2 \[Pi]}, "ColorFunctionSurface" -> Function[{x, y, z}, Hue[z]]]
Out[9]=

Set a color function for both the surface and the sections:

In[10]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {{Cos[t], Sin[t], Cos[2 t]}, {1/2 Cos[t], 1/2 Sin[t], 1/4 Cos[2 t]}}, {t, 0, 2 \[Pi]},
 "ColorFunctionSurface" -> Function[{x, y, z}, Hue[z]], "ColorFunctionSection" -> Function[{x, y, z}, GrayLevel[z]]]
Out[10]=

CylinderBase (1) 

Set where to place the base of the cylinder:

In[11]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "CylinderBase" -> -2, BoxRatios -> Automatic]
Out[11]=

CylinderRange (5) 

Set the cylinder to be drawn from the top of the bounding box down to the surface:

In[12]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, BoxRatios -> Automatic, "CylinderRange" -> Reverse]
Out[12]=

Draw the cylinder both above and below the surface:

In[13]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, BoxRatios -> Automatic, "CylinderRange" -> {-2, 2}]
Out[13]=

Draw the cylinder to full height:

In[14]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "CylinderBase" -> -2, BoxRatios -> Automatic, "CylinderRange" -> All]
Out[14]=

Draw a cylinder from a base of −2 to the surface (this is the same as setting CylinderBase−2):

In[15]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, BoxRatios -> Automatic, "CylinderRange" -> {-2, Automatic}]
Out[15]=

CylinderRange takes precedence over CylinderBase:

In[16]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {Cos[t], Sin[t]}, {t, 0, 2 \[Pi]}, "CylinderRange" -> All, "CylinderBase" -> -2, BoxRatios -> Automatic]
Out[16]=
In[17]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "CylinderRange" -> All, "CylinderBase" -> -2, BoxRatios -> Automatic]
Out[17]=

CylinderStyle (1) 

Apply a style to the cylinder:

In[18]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "CylinderStyle" -> Opacity[1]]
Out[18]=

DrawCylinder (1) 

Suppress the plot of the cylinder:

In[19]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "DrawCylinder" -> False]
Out[19]=

DrawPoint and DrawPointStyle (2) 

When "DrawPoint" contains one or more 2-tuples, then the point determined by these 2-tuples is found by substituting these parameter values into the definition of the function:

In[20]:=
{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]} /. ResourceFunction[
   "PointsToRules"][{{0, 1}, {\[Pi]/2, 1}, {\[Pi], 1}, {3 \[Pi]/2, 1}}, {t, r}]
Out[20]=

Points given by 3-tuples have their usual meaning as (x,y,z)-coordinates:

In[21]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[u], 3 Sin[u], Sin[6 Cos[u] Sin[u]]}, {u, 0, 2 \[Pi]}, "DrawPoint" -> {{0, 1}, {\[Pi]/2, 1}, {\[Pi], 1}, {3 \[Pi]/2, 1}, {1,
     1, 3}}, "DrawPointStyle" -> {{PointSize[.05], Red}, {PointSize[.05], Orange}, {PointSize[.06], Green}, {PointSize[.06], Blue}, {PointSize[.08], Magenta}}]
Out[21]=

OSection (2) 

Cutting the cone with a plane not passing through the vertex of the cone and not parallel to an axis of the cone will give an ellipse. Note that the variables used to specify the plane must be given in a list:

In[22]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, 0, 3}, "OSection" -> {(3 y)/4 + .5}, "SectionVariables" -> {x, y}, "DrawPoint" -> {1, 0}]
Out[22]=

When the plane is parallel to the side of the cone, a parabola is generated:

In[23]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, 0, 3}, "OSection" -> {w + 2}, "SectionVariables" -> {x, w}]
Out[23]=

OSectionStyle (1) 

Add styles:

In[24]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, 0, 3}, "OSection" -> {w + 2}, "SectionVariables" -> {x, w}, "OSectionStyle" -> Blue]
Out[24]=

PlotPointsSection (1) 

Change the number of points used to plot the section(s). Since the Wolfram Language’s plotting commands use adaptive procedures to determine how many points to actually plot, this feature must be turned off by setting the option MaxRecursion:

In[25]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {1/(1 + t^2) Cos[5 t], 1/(1 + t^2) Sin[5 t]}, {t, 0, 2 \[Pi]}, Mesh -> None, "PlotPointsSection" -> 25, MaxRecursion -> 0]
Out[25]=

PlotStyle (1) 

Apply a style to the surface:

In[26]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, PlotStyle -> {{Opacity[.8], Orange}}, Mesh -> None]
Out[26]=

SectionStyle (1) 

Apply styles to the section:

In[27]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r^2 Cos[2 t]}, {r, 0,
   1}, {t, 0, 2 \[Pi]}, {Cos[t], Sin[t], Cos[2 t]}, {t, 0, 2 \[Pi]}, "SectionStyle" -> {{Tube[.03], Magenta}}]
Out[27]=

Surface (1) 

Suppress the plot of the surface:

In[28]:=
GraphicsRow[{ResourceFunction[
   "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[t], Sin[t], Sin[2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, "CylinderStyle" -> Opacity[1]], ResourceFunction[
   "SectionParametricPlot3D"][{r Cos[t], r Sin[t], Sin[r^2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, {r, 0, 3}, {2 Cos[t], Sin[t], Sin[2 Cos[t] Sin[t]]}, {t, 0, 2 \[Pi]}, "CylinderStyle" -> Opacity[1], "Surface" -> False]}, ImageSize -> Full]
Out[28]=

VSection (2) 

Add vertical sections (remember that sections’ variables must be specified):

In[29]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "VSection" -> {y == x + .5}, "SectionVariables" -> {x, y}, "CylinderStyle" -> Opacity[.5]]
Out[29]=

VSections can be any function of x or y:

In[30]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "VSection" -> {x == Sin[2 y], y == x^2}, "SectionVariables" -> {x, y}]
Out[30]=

VSectionStyle (1) 

Set style for the sections:

In[31]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "VSection" -> {x == Sin[2 y], y == x^2}, "SectionVariables" -> {x, y}, "CylinderStyle" -> Opacity[.5], "VSectionStyle" -> {Red, Blue}]
Out[31]=

XSection (1) 

The intersection of planes of the form x=a with a cone generate either hyperbolas or lines:

In[32]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "XSection" -> {-(3/4), 0}]
Out[32]=

XSectionStyle (1) 

Assign a style to the XSection:

In[33]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "XSection" -> {-(3/4), 0}, "XSectionStyle" -> {Blue, Purple}]
Out[33]=

YSection (1) 

Add a YSection:

In[34]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "YSection" -> -(1/2)]
Out[34]=

YSectionStyle (1) 

Set a style for the YSection:

In[35]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "YSection" -> -(1/2), "YSectionStyle" -> Pink]
Out[35]=

ZSection (1) 

Add ZSections:

In[36]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "ZSection" -> {-.5, .5}]
Out[36]=

ZSectionStyle (1) 

Set a style for the ZSections:

In[37]:=
ResourceFunction[
 "SectionParametricPlot3D"][{r Cos[t], r Sin[t], r}, {t, 0, 2 \[Pi]}, {r, -1, 1}, "ZSection" -> {-.5, .5}, "ZSectionStyle" -> {Green, Blue}]
Out[37]=

Publisher

Dennis M Schneider

Version History

  • 1.0.0 – 05 November 2019

Related Resources

License Information