Interpolating Functions to Approximate Volumes

This notebook utilizes digital photos and the method of cross sections to approximate the volume of a sea worm. A digital photograph is read and the "edges" of the worm are approximated using an interpolating function (by default a third order interpolation function). The cross sections are constructed and displayed in an animation. The volume is approximated using a sum of the volumes of cross-sectional disks and also by using an integral involving the interpolating functions.

Read in graphics packages and turn off spelling checks (turning off spelling checks is merely a convenience).

In[1]:=

Import the digital photo. This demo does not account for forshortening so it is useful to include in a photo some article such as a ruler that would give a sense of scale. In this example, the photo is in JPEG format with a resolution of 72 pixels/inch. This will be used in the calculations. NOTE: If you use your own photograph or if you download the image, you will need to change the path before executing.

In[8]:=

Out[8]=

In[9]:=

Out[9]=

Select points along the top edge of the worm in the photograph. Click on the picture and while holding the Control Key, click the edge while moving from left to right (if you look carefully you will see white pixels corresponding to the selected points). After selecting the points, choose Edit->Copy to copy the coordinates on the clipboard. Then paste into the notebook input cell for the variable "toppoints".

In[10]:=

Compute interpolating function and find maximum and minimum domain and range values. These values will be used later when constructing graphs.

In[11]:=

In[12]:=

Select points along the bottom edge of the photograph using the same approach as for the top points. Copy and paste into the input for variable "bottompoints."

In[18]:=

Compute interpolating function and find maximum and minimum domain and range values. These values will be used later when constructing graphs.

In[19]:=

In[20]:=

Compute upper and lower bounds for the graphs.

In[26]:=

Set PlotRange for the 3D plots. The parameter "addabit" gives a little space around the actual graph. It can be adjusted to suit the user.

In[28]:=

In[29]:=

Show the interpolating function that fits the points.

In[30]:=

Out[30]=

In[31]:=

Out[31]=

Set up the partition.

In[32]:=

In[36]:=

Locate the centers of the circular cross sections and the radius function which is computed as 1/2 (top(x) - bottom(x)).

In[37]:=

Set up the ends of the cross sectional pieces and store as a graphics array.

In[39]:=

Out[39]=

In[40]:=

Out[40]=

Set up the circular outside edges of the cross sections.

In[41]:=

Represent the filled region in the vertical plane using rectangles.

In[42]:=

In[46]:=

Out[46]=

Show the region and the partition.

In[47]:=

Out[47]=

Generate a 3-dimensional model of the worm.

In[48]:=

Generate the approximating cross sections as a sequence of frames that can be animated.

In[49]:=

Approximate the volume using NIntegrate. Because the interpolating functions are piecewise, NIntegrate may not always give convergence of the integral. This can be avoided by limiting the number of points at which Mathematica computes function values. In this example, the option MaxPoints is set to 100000000. The integral is scaled by 1/72^3 because the resolution of the photograph is 72 pixels per inch.

In[50]:=

Out[50]=

Convert to ml. 1 sqare inch is approximately 16.387 ml.

In[51]:=

Out[51]=

Approximate the volume using a sum of the volumes of the approximating cross sections and convert to ml.

In[52]:=

Out[52]=

In[53]:=

Out[53]=

The codes below are not necessary for the demonstration but might be helpful if you wish to generate demos using a different photograph. The two code sequences illustrate the selecton of the points along top and bottom and the generation of the interpolation functions.

In[54]:=

In[55]:=

This Mathematica notebook was developed for Demos with Positive Impact (NSF DUE-9952306) by

Lila F. Roberts (lila.roberts@gcsu.edu)

Georgia College and State University

Special thanks to James P. Braselton (jbraselton@georgiasouthern.edu) for Mathematica advice and assistance.

Created by Mathematica (December 31, 2003)