3D Graphics Examples

Math 213 - Math with Mathematica
Christopher Hanusa

Overview

We will use the ideas from Tutorials 9 and 10 to attack some more complicated examples.

ListSurfacePlot3D

When you have a large number of 3D points that you would like to connect, use ListSurfacePlot3D.

data=ExampleData[{"Geometry3D","StanfordBunny"},"VertexData"];

ListPointPlot3D[data]

ListSurfacePlot3D[data,MaxPlotPoints->50]

Comprehension Question

Create a dataset of 1000 points that are on a perfect cube.  Use ListSurfacePlot3D to draw the cube.

BSplineSurface

If you have ((Subscript[x, i]),(Subscript[y, i]),(Subscript[z, i])) control points and you’d like a surface that is a smooth function z=f(x,y), then use BSplineSurface

cpts=Table[{i,j,RandomReal[{-1,1}]},{i,5},{j,5}];

b=Graphics3D[BSplineSurface[cpts]]

Show[Graphics3D[{PointSize[Medium],Red,Map[Point,cpts],Gray,Line[cpts],Line[Transpose[cpts]]}],b]

Comprehension Question

Generate some (x,y,z) points that have some meaning (like on a paraboloid) and apply BSplineSurface to give the surface.  
Modify the points slightly and see how it changes the surface.

Example:  Costa Rica Pendant

CREdges=CountryData[Entity["Country","CostaRica"],"Polygon"][[1,1,1]];

Graphics3D[{Polygon[Map[Prepend[#,0]&,CREdges]],Polygon[Map[Prepend[#,0.25]&,CREdges]]}]

Graphics3D[{Table[Polygon[{
Prepend[CREdges[[i]],0],
Prepend[CREdges[[Mod[i+1,Length[CREdges],1]]],0],
Prepend[CREdges[[Mod[i+1,Length[CREdges],1]]],0.25],
Prepend[CREdges[[i]],0.25]}],{i,Length[CREdges]}]}]

Comprehension Question

Merge the two parallel plates with the edges to create a solid pendant.

Example: Hyperbolic Paraboloid Surface

This code was generously published by Henry Segerman in his preprint: 3D printing for mathematical visualisation. 
(Read page 7 of http://www.ms.unimelb.edu.au/~segerman/papers/3d_printed_visualisation.pdf, where he describes what each line does)

f[u_,v_]:={u,v,u^2−v^2};
scale=40;
radius=0.75;
numPoints=24;
gridSteps=10;
curvesU=Table[scale f[u,i],{i,−1,1,2/gridSteps}];
curvesV=Table[scale f[j,v],{j,−1,1,2/gridSteps}];
tubesU=ParametricPlot3D[curvesU,{u,−1,1},PlotStyle->Tube[radius,PlotPoints->numPoints],PlotRange->All];
tubesV=ParametricPlot3D[curvesV,{v,−1,1},PlotStyle->Tube[radius,PlotPoints->numPoints],PlotRange->All];
corners=Graphics3D[Table[Sphere[scale f[i,j],radius],{i,−1,1,2},{j,−1,1,2}],PlotPoints->numPoints];
output=Show[tubesU,tubesV,corners]

Comprehension Question

Modify the surface to something different that you find more appealing.

Example: Create a die with pips using RegionPlot3D.

pip=.04;
RegionPlot3D[Abs[x]≤1&&Abs[y]≤1&&Abs[z]≤1&&
(* 1 side *)
(x^2+y^2+(z-1)^2≥pip)&&
(* 6 side *)
((x+.5)^2+y^2+(z+1)^2≥pip)&&
((x+.5)^2+(y+.5)^2+(z+1)^2≥pip)&&
((x+.5)^2+(y-.5)^2+(z+1)^2≥pip)&&
((x-.5)^2+y^2+(z+1)^2≥pip)&&
((x-.5)^2+(y+.5)^2+(z+1)^2≥pip)&&
((x-.5)^2+(y-.5)^2+(z+1)^2≥pip)&&
(* 2 side *)
((x-1)^2+(y+.5)^2+(z+.5)^2≥pip)&&
((x-1)^2+(y-.5)^2+(z-.5)^2≥pip) &&
(* 5 side *)
(* 3 side *)
(x^2+(y-1)^2+z^2≥pip)&&
((x+.5)^2+(y-1)^2+(z+.5)^2≥pip)&&
((x-.5)^2+(y-1)^2+(z-.5)^2≥pip) &&
(* 4 side *)
((x+.5)^2+(y+1)^2+(z+.5)^2≥pip)&&
((x+.5)^2+(y+1)^2+(z-.5)^2≥pip)&&
((x-.5)^2+(y+1)^2+(z+.5)^2≥pip)&&
((x-.5)^2+(y+1)^2+(z-.5)^2≥pip)
,{x,-1.5,1.5},{y,-1.5,1.5},{z,-1.5,1.5},PlotPoints->50,PlotStyle->White,Mesh->None,Axes->False,Boxed->False]

Comprehension Question

Put in the pips on the last side of the die.

Solutions

Die Die Die

((x+1)^2+y^2+z^2≥pip)&&
((x+1)^2+(y+.5)^2+(z+.5)^2≥pip)&&
((x+1)^2+(y+.5)^2+(z-.5)^2≥pip)&&
((x+1)^2+(y-.5)^2+(z+.5)^2≥pip)&&
((x+1)^2+(y-.5)^2+(z-.5)^2≥pip)&&