Cylinders and Quadric Surfaces

Introduction

To plot three dimensional functions in Mathematica we use the ContourPlot3D command. We define the surface as f[x,y,z]=0, and we can generate all the nice looking plots we see in our text book. For starters, lets get a hyperboloid of one sheet:

surface1 = x^2/4+y^2-z^2/4-1
surface1plot = ContourPlot3D[surface1,{x,-5,5},{y,-5,5},{z,-5,5},Contours->0, Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

A trace (or cross-section) is the intersection of the surface with planes parallel to the coordinate axes. A horizontal trace is the intersection of the surface with the xy-plane (assuming z points up), and a vertical trace intersects either the xz or yz-planes. The equation for the horizontal traces comes from setting z to be the constant k, so the equations are ellipses in x,y:

0== surface1 /. z-> k

We can change the view point without recalculating the surface, by using the Show command. This is incredibly useful if we want to see the horizontal and vertical traces of the surface. For the Hyperboloid above, we can shift the viewpoint to (x,y,z)=(0,0,10), which means we are looking down at the hyperboloid, and we see that the horizontal traces are ellipses.

Manipulate[Show[surface1plot,ViewPoint->{10-2n,2n-10,10},Axes->False],{n,0,5}]

Show[surface1plot,ViewPoint->{0,0,10}]

The vertical traces of the hyperboloid are hyperbolas (hence the name!). We see this with both the projection onto the xz-plane:

Show[surface1plot,ViewPoint->{0,10,0}]

and the yz-plane:

Show[surface1plot,ViewPoint->{10,0,0}]

Notice that the projection is skinnier in the yz-plane since the equations for the hyberbolas in the two planes are different:

0== surface1 /. y-> k
0== surface1 /. x-> k

Rather than using the Show command to see the traces, we could also use the ContourPlot command. For this, we need to write the surface equation in the form z=f[x,y].

ContourPlot[2  (Sqrt[-1+((x^2)/4)+(y^2)]),{x,-5,5},{y,-5,5},ContourShading->False,Contours->20, Axes->True,AxesLabel->{"x-axis","y-axis"}]

See the ellipses in the xy-plane? We can also generate the ellipses in the xz and yz plane:

ContourPlot[2  (Sqrt[-1-((z^2)/4)+((x^2)/4)]),{x,-10,10},{z,-10,10},ContourShading->False,Contours->20, Axes->True,AxesLabel->{"x-axis","z-axis"}]

The following commands generate the quadric surfaces and their traces. You should experiment with changing the parameters in the quadric definition, the parameters in the plots, and anything else you like. Remember that the function we are plotting is actually f[x,y,z]=0.

Cylinder:

cylinder = x^2+z^2-4
cylinderplot = ContourPlot3D[cylinder,{x,-5,5},{y,-4,4},{z,-7,7},Axes->True,Contours->0,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[cylinderplot,ViewPoint->{0,0,10}]

Vertical traces (ellispes):

Show[cylinderplot,ViewPoint->{0,10,0},Axes->False]
Show[cylinderplot,ViewPoint->{10,0,0},Axes->False]

Hyperbolic Cylinder:

hyperboliccylinder = y^2-z^2-4
hyperboliccylinderplot = ContourPlot3D[hyperboliccylinder,{x,-5,5},{y,-4,4},{z,-7,7},Axes->True,Contours->0,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[hyperboliccylinderplot,ViewPoint->{0,0,10}]

Vertical traces (ellispes):

Show[hyperboliccylinderplot,ViewPoint->{0,10,0},Axes->False]
Show[hyperboliccylinderplot,ViewPoint->{10,0,0},Axes->False]

Ellipsoid:

ellipsoid = x^2/4^2+y^2/3^2+z^2/6^2-1
ellipsoidplot = ContourPlot3D[ellipsoid,{x,-5,5},{y,-4,4},{z,-7,7},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[ellipsoidplot,ViewPoint->{0,0,10}]

Vertical traces (ellispes):

Show[ellipsoidplot,ViewPoint->{0,10,0},Axes->False]
Show[ellipsoidplot,ViewPoint->{10,0,0},Axes->False]

Cone:

cone = x^2/4^2+y^2/3^2-z^2/6^2
coneplot = ContourPlot3D[cone,{x,-5,5},{y,-4,4},{z,-7,7},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[coneplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces (hyberbolas unless x=y=0, then they are a pair of lines):

Show[coneplot,ViewPoint->{0,10,0},Axes->False]
Show[coneplot,ViewPoint->{10,0,0},Axes->False]

Elliptic Paraboloid:

ellipticparaboloid = x^2/4^2+y^2/3^2-z/6
epplot = ContourPlot3D[ellipticparaboloid,{x,-5,5},{y,-4,4},{z,-7,7},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[epplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces (hyberbolas):

Show[epplot,ViewPoint->{0,10,0},Axes->False]
Show[epplot,ViewPoint->{10,0,0},Axes->False]

Hyperboloid of one sheet:

hyper1sheet = x^2/4^2+y^2/3^2-z^2/2^2 - 1
hyper1sheetplot = ContourPlot3D[hyper1sheet,{x,-5,5},{y,-4,4},{z,-7,7},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses):

Show[hyper1sheetplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces (hyberbolas):

Show[hyper1sheetplot,ViewPoint->{0,10,0},Axes-> False]
Show[hyper1sheetplot,ViewPoint->{10,0,0},Axes->False]

Hyperbolic Paraboloid:

hyperpara = x^2/4^2-y^2/3^2-z/6
hpplot = ContourPlot3D[hyperpara,{x,-10,10},{y,-6,6},{z,-7,7},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (hyperbolas):

Show[hpplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces (parabolas):

Show[hpplot,ViewPoint->{0,10,0},Axes->False]
Show[hpplot,ViewPoint->{10,0,0},Axes->False]

Hyperboloid of two sheets:

hyper2sheet = - x^2/4^2-y^2/3^2+z^2/2^2 - 1
hyper2sheetplot = ContourPlot3D[hyper2sheet,{x,-10,10},{y,-10,10},{z,-10,10},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace (ellipses if z=k>2 or z=k<-2):

Show[hyper2sheetplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces (hyberbolas):

Show[hyper2sheetplot,ViewPoint->{0,10,0},Axes->False]
Show[hyper2sheetplot,ViewPoint->{10,0,0},Axes->False]

All Quadric Surfaces Together:

Show[GraphicsGrid[{{ellipsoidplot,coneplot,epplot},{hyper1sheetplot,hpplot ,hyper2sheetplot}}]]

General Quadric Surface:

quad = z-y^2-x y
quadplot = ContourPlot3D[quad,{x,-10,10},{y,-5,5},{z,-10,10},Contours->0,Axes->True,AxesLabel->{"x-axis","y-axis","z-axis"}]

Horizontal trace:

Show[quadplot,ViewPoint->{0,0,10},Axes->False]

Vertical traces:

Show[quadplot,ViewPoint->{0,10,0},Axes->False]
Show[quadplot,ViewPoint->{10,0,0},Axes->False]