The steps in the color are made possible by the **floor function**, floor(x),
which is the greatest integer less than or equal to x. (For example, floor(3.2) = 3, floor(7) = 7, and floor(-3.2) = -4.) This floor function has just recently been
added to DPGraph.

To begin with, I got out a ruler and measured the toy and found that the total height of the model is about 13 cm, and the width is about 6.2 cm. The coordinates used in DPGraph are measured in cm. The dividing lines between the colors are:

n | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|

z_{n} | 0 | 3.0 | 5.8 | 8.4 | 10.8 | 13.0 |

We want the color to be blue for all z between 0.0 and 3.0, green for all z between 3.0 and
5.8, etc. The heights z_{n} have constant *second difference*, since
the differences are 3.0, 2.8, 2.6, 2.4 and 2.2.
It is well-known that *quadratic* functions have a constant second difference,
and it's not too hard to show that z_{n} = (31 n - n^{2})/10.
(Hint: I set z_{n} = 13/5 n + c n (5-n) and solved for c.) This can then be
inverted to find n = 31/2 - sqrt(961/4 - 10 z_{n}). The floor function
then makes n = floor( 31/2 - sqrt(961/4 - 10 z_{n}) ) equal to 0 for z between
0 and 3, equal to 1 for z between 3 and 5.8, etc.

The next step is converting the integer n to the correct color. We want the bottom donut, n = 0, to be blue (color = 1/3) and the top donut, n = 4, to be red (color = 1). A simple linear function, color = 1/3 + 1/6 n, does not produce very good results. I used the color function color = 1/3 + 1/3 sqrt(n), which maps z = 0 to color = 1/3 and z = 4 to color = 1 like the linear function. However, the new color function makes color take a big jumb between n = 0 and n = 1, but smaller and smaller jumps as n increases.

These graphs were produced by
DPGraph,
which is a ** fast** program for
viewing 3D objects.

e-mail: Jim.Swift@nau.edu