Notes for Tuesday April 17:

Bezier curve subdivision

We can subdivide a Bezier curve into two Bezier curves. We get exactly the same shape, but now we have the control to add detaile in selected places.

Doing this recursively lets us add more detail to some local parts of the curve, without needing to create lots of spline curves everywhere.

AB = mix(A, B, 1/2)
BC = mix(B, C, 1/2)
CD = mix(C, D, 1/2)

A1 = A
B1 = AB
C1 = mix(AB, BC, 1/2)
D1 = BC

A2 = BC
B2 = mix(BC, CD, 1/2)
C2 = CD
D2 = D

Bezier bicubic patch surfaces

We can define a Bezier bicubic patch surface element via an array of 4×4 control points:

G00 G10 G20 G30
G01 G11 G21 G31
G02 G12 G22 G32
G03 G13 G23 G33
To compute any given coordinate of the Bezier bicubic patch surface for any (u,v) value on the patch, we use that coordinate (eg: the X coordinate) of each control point, and find its value on the surface at (u,v) as follows:

v3 v2 v 1   ●  
-1  3 -3  1
 3 -6  3  0
-3  3  0  0
 1  0  0  0
  ●  
X00 X10 X20 X30
X01 X11 X21 X31
X02 X12 X22 X32
X03 X13 X23 X33
  ●  
-1  3 -3  1
 3 -6  3  0
-3  3  0  0
 1  0  0  0
  ●   u3
u2
u
1

Newell teapot

Below you can see the actual teapot that sat on Martin Newell's desk in the University of Utah, from which he developed the "Utah Teapot" computer graphics model in 1974.

I took this photo in the Computer History Museum in Mountain View, California, where the teapot currently resides.

Behind the teapot itself, you can see several computer graphic renderings of the teapot.

Homework (due before class this coming Tuesday)

Create and render a bezier surface patch. In order to render it, you will need to iterate over u and v. Think of it as a parametric surface, and just use the function we described above to map from any particular (u,v) value to each (x,y,z) value on the patch surface.

You can use the method for finding normals that we developed last week to assign a surface normal to each surface point.

For extra credit, see if you can figure out how to subdivide the Bezier bicubic surface patch into four subpatches. If you do this to multiple levels, then you can add surface detail to only one part of the surface, without disturbing the entire surface or needing to add lots of surface patches everywhere.

Also for extra credit, see if you can re-create the original Newell teapot. The Bezier data is below. Every group of 3 numbers is a set of x,y,z coordinates, so each patch is determined by 16×3 or 48 numbers.

let teapot_data = [ // 0
 -80.00,   0.00,  30.00,  -80.00, -44.80,  30.00,  -44.80, -80.00,  30.00,    0.00, -80.00,  30.00,
 -80.00,   0.00,  12.00,  -80.00, -44.80,  12.00,  -44.80, -80.00,  12.00,    0.00, -80.00,  12.00,
 -60.00,   0.00,   3.00,  -60.00, -33.60,   3.00,  -33.60, -60.00,   3.00,    0.00, -60.00,   3.00,
 -60.00,   0.00,   0.00,  -60.00, -33.60,   0.00,  -33.60, -60.00,   0.00,    0.00, -60.00,   0.00,
],[
  0.00, -80.00,  30.00,   44.80, -80.00,  30.00,   80.00, -44.80,  30.00,   80.00,   0.00,  30.00,
  0.00, -80.00,  12.00,   44.80, -80.00,  12.00,   80.00, -44.80,  12.00,   80.00,   0.00,  12.00,
  0.00, -60.00,   3.00,   33.60, -60.00,   3.00,   60.00, -33.60,   3.00,   60.00,   0.00,   3.00,
  0.00, -60.00,   0.00,   33.60, -60.00,   0.00,   60.00, -33.60,   0.00,   60.00,   0.00,   0.00,
],[
 -60.00,   0.00,  90.00,  -60.00, -33.60,  90.00,  -33.60, -60.00,  90.00,    0.00, -60.00,  90.00,
 -70.00,   0.00,  69.00,  -70.00, -39.20,  69.00,  -39.20, -70.00,  69.00,    0.00, -70.00,  69.00,
 -80.00,   0.00,  48.00,  -80.00, -44.80,  48.00,  -44.80, -80.00,  48.00,    0.00, -80.00,  48.00,
 -80.00,   0.00,  30.00,  -80.00, -44.80,  30.00,  -44.80, -80.00,  30.00,    0.00, -80.00,  30.00,
],[
  0.00, -60.00,  90.00,   33.60, -60.00,  90.00,   60.00, -33.60,  90.00,   60.00,   0.00,  90.00,
  0.00, -70.00,  69.00,   39.20, -70.00,  69.00,   70.00, -39.20,  69.00,   70.00,   0.00,  69.00,
  0.00, -80.00,  48.00,   44.80, -80.00,  48.00,   80.00, -44.80,  48.00,   80.00,   0.00,  48.00,
  0.00, -80.00,  30.00,   44.80, -80.00,  30.00,   80.00, -44.80,  30.00,   80.00,   0.00,  30.00,
],[
 -56.00,   0.00,  90.00,  -56.00, -31.36,  90.00,  -31.36, -56.00,  90.00,    0.00, -56.00,  90.00,
 -53.50,   0.00,  95.25,  -53.50, -29.96,  95.25,  -29.96, -53.50,  95.25,    0.00, -53.50,  95.25,
 -57.50,   0.00,  95.25,  -57.50, -32.20,  95.25,  -32.20, -57.50,  95.25,    0.00, -57.50,  95.25,
 -60.00,   0.00,  90.00,  -60.00, -33.60,  90.00,  -33.60, -60.00,  90.00,    0.00, -60.00,  90.00,
],[ // 5
  0.00, -56.00,  90.00,   31.36, -56.00,  90.00,   56.00, -31.36,  90.00,   56.00,   0.00,  90.00,
  0.00, -53.50,  95.25,   29.96, -53.50,  95.25,   53.50, -29.96,  95.25,   53.50,   0.00,  95.25,
  0.00, -57.50,  95.25,   32.20, -57.50,  95.25,   57.50, -32.20,  95.25,   57.50,   0.00,  95.25,
  0.00, -60.00,  90.00,   33.60, -60.00,  90.00,   60.00, -33.60,  90.00,   60.00,   0.00,  90.00,
],[
 80.00,   0.00,  30.00,   80.00,  44.80,  30.00,   44.80,  80.00,  30.00,    0.00,  80.00,  30.00,
 80.00,   0.00,  12.00,   80.00,  44.80,  12.00,   44.80,  80.00,  12.00,    0.00,  80.00,  12.00,
 60.00,   0.00,   3.00,   60.00,  33.60,   3.00,   33.60,  60.00,   3.00,    0.00,  60.00,   3.00,
 60.00,   0.00,   0.00,   60.00,  33.60,   0.00,   33.60,  60.00,   0.00,    0.00,  60.00,   0.00,
],[
  0.00,  80.00,  30.00,  -44.80,  80.00,  30.00,  -80.00,  44.80,  30.00,  -80.00,   0.00,  30.00,
  0.00,  80.00,  12.00,  -44.80,  80.00,  12.00,  -80.00,  44.80,  12.00,  -80.00,   0.00,  12.00,
  0.00,  60.00,   3.00,  -33.60,  60.00,   3.00,  -60.00,  33.60,   3.00,  -60.00,   0.00,   3.00,
  0.00,  60.00,   0.00,  -33.60,  60.00,   0.00,  -60.00,  33.60,   0.00,  -60.00,   0.00,   0.00,
],[
 60.00,   0.00,  90.00,   60.00,  33.60,  90.00,   33.60,  60.00,  90.00,    0.00,  60.00,  90.00,
 70.00,   0.00,  69.00,   70.00,  39.20,  69.00,   39.20,  70.00,  69.00,    0.00,  70.00,  69.00,
 80.00,   0.00,  48.00,   80.00,  44.80,  48.00,   44.80,  80.00,  48.00,    0.00,  80.00,  48.00,
 80.00,   0.00,  30.00,   80.00,  44.80,  30.00,   44.80,  80.00,  30.00,    0.00,  80.00,  30.00,
],[
  0.00,  60.00,  90.00,  -33.60,  60.00,  90.00,  -60.00,  33.60,  90.00,  -60.00,   0.00,  90.00,
  0.00,  70.00,  69.00,  -39.20,  70.00,  69.00,  -70.00,  39.20,  69.00,  -70.00,   0.00,  69.00,
  0.00,  80.00,  48.00,  -44.80,  80.00,  48.00,  -80.00,  44.80,  48.00,  -80.00,   0.00,  48.00,
  0.00,  80.00,  30.00,  -44.80,  80.00,  30.00,  -80.00,  44.80,  30.00,  -80.00,   0.00,  30.00,
],[ // 10
 56.00,   0.00,  90.00,   56.00,  31.36,  90.00,   31.36,  56.00,  90.00,    0.00,  56.00,  90.00,
 53.50,   0.00,  95.25,   53.50,  29.96,  95.25,   29.96,  53.50,  95.25,    0.00,  53.50,  95.25,
 57.50,   0.00,  95.25,   57.50,  32.20,  95.25,   32.20,  57.50,  95.25,    0.00,  57.50,  95.25,
 60.00,   0.00,  90.00,   60.00,  33.60,  90.00,   33.60,  60.00,  90.00,    0.00,  60.00,  90.00,
],[
  0.00,  56.00,  90.00,  -31.36,  56.00,  90.00,  -56.00,  31.36,  90.00,  -56.00,   0.00,  90.00,
  0.00,  53.50,  95.25,  -29.96,  53.50,  95.25,  -53.50,  29.96,  95.25,  -53.50,   0.00,  95.25,
  0.00,  57.50,  95.25,  -32.20,  57.50,  95.25,  -57.50,  32.20,  95.25,  -57.50,   0.00,  95.25,
  0.00,  60.00,  90.00,  -33.60,  60.00,  90.00,  -60.00,  33.60,  90.00,  -60.00,   0.00,  90.00,
],[
 -64.00,   0.00,  75.00,  -64.00,  12.00,  75.00,  -60.00,  12.00,  84.00,  -60.00,   0.00,  84.00,
 -92.00,   0.00,  75.00,  -92.00,  12.00,  75.00, -100.00,  12.00,  84.00, -100.00,   0.00,  84.00,
   -108.00,   0.00,  75.00, -108.00,  12.00,  75.00, -120.00,  12.00,  84.00, -120.00,   0.00,  84.00,
   -108.00,   0.00,  66.00, -108.00,  12.00,  66.00, -120.00,  12.00,  66.00, -120.00,   0.00,  66.00,
],[
 -60.00,   0.00,  84.00,  -60.00, -12.00,  84.00,  -64.00, -12.00,  75.00,  -64.00,   0.00,  75.00,
   -100.00,   0.00,  84.00, -100.00, -12.00,  84.00,  -92.00, -12.00,  75.00,  -92.00,   0.00,  75.00,
   -120.00,   0.00,  84.00, -120.00, -12.00,  84.00, -108.00, -12.00,  75.00, -108.00,   0.00,  75.00,
   -120.00,   0.00,  66.00, -120.00, -12.00,  66.00, -108.00, -12.00,  66.00, -108.00,   0.00,  66.00,
],[
   -108.00,   0.00,  66.00, -108.00,  12.00,  66.00, -120.00,  12.00,  66.00, -120.00,   0.00,  66.00,
   -108.00,   0.00,  57.00, -108.00,  12.00,  57.00, -120.00,  12.00,  48.00, -120.00,   0.00,  48.00,
   -100.00,   0.00,  39.00, -100.00,  12.00,  39.00, -106.00,  12.00,  31.50, -106.00,   0.00,  31.50,
 -80.00,   0.00,  30.00,  -80.00,  12.00,  30.00,  -76.00,  12.00,  18.00,  -76.00,   0.00,  18.00,
],[ // 15
   -120.00,   0.00,  66.00, -120.00, -12.00,  66.00, -108.00, -12.00,  66.00, -108.00,   0.00,  66.00,
   -120.00,   0.00,  48.00, -120.00, -12.00,  48.00, -108.00, -12.00,  57.00, -108.00,   0.00,  57.00,
   -106.00,   0.00,  31.50, -106.00, -12.00,  31.50, -100.00, -12.00,  39.00, -100.00,   0.00,  39.00,
 -76.00,   0.00,  18.00,  -76.00, -12.00,  18.00,  -80.00, -12.00,  30.00,  -80.00,   0.00,  30.00,
],[
 68.00,   0.00,  51.00,   68.00,  26.40,  51.00,   68.00,  26.40,  18.00,   68.00,   0.00,  18.00,
 104.00,   0.00,  51.00,  104.00,  26.40,  51.00,  124.00,  26.40,  27.00,  124.00,   0.00,  27.00,
 92.00,   0.00,  78.00,   92.00,  10.00,  78.00,   96.00,  10.00,  75.00,   96.00,   0.00,  75.00,
 108.00,   0.00,  90.00,  108.00,  10.00,  90.00,  132.00,  10.00,  90.00,  132.00,   0.00,  90.00,
],[
 68.00,   0.00,  18.00,   68.00, -26.40,  18.00,   68.00, -26.40,  51.00,   68.00,   0.00,  51.00,
 124.00,   0.00,  27.00,  124.00, -26.40,  27.00,  104.00, -26.40,  51.00,  104.00,   0.00,  51.00,
 96.00,   0.00,  75.00,   96.00, -10.00,  75.00,   92.00, -10.00,  78.00,   92.00,   0.00,  78.00,
 132.00,   0.00,  90.00,  132.00, -10.00,  90.00,  108.00, -10.00,  90.00,  108.00,   0.00,  90.00,
],[
 108.00,   0.00,  90.00,  108.00,  10.00,  90.00,  132.00,  10.00,  90.00,  132.00,   0.00,  90.00,
 112.00,   0.00,  93.00,  112.00,  10.00,  93.00,  141.00,  10.00,  93.75,  141.00,   0.00,  93.75,
 116.00,   0.00,  93.00,  116.00,   6.00,  93.00,  138.00,   6.00,  94.50,  138.00,   0.00,  94.50,
 112.00,   0.00,  90.00,  112.00,   6.00,  90.00,  128.00,   6.00,  90.00,  128.00,   0.00,  90.00,
],[
 132.00,   0.00,  90.00,  132.00, -10.00,  90.00,  108.00, -10.00,  90.00,  108.00,   0.00,  90.00,
 141.00,   0.00,  93.75,  141.00, -10.00,  93.75,  112.00, -10.00,  93.00,  112.00,   0.00,  93.00,
 138.00,   0.00,  94.50,  138.00,  -6.00,  94.50,  116.00,  -6.00,  93.00,  116.00,   0.00,  93.00,
 128.00,   0.00,  90.00,  128.00,  -6.00,  90.00,  112.00,  -6.00,  90.00,  112.00,   0.00,  90.00,
],[ // 20
 50.00,   0.00,  90.00,   50.00,  28.00,  90.00,   28.00,  50.00,  90.00,    0.00,  50.00,  90.00,
 52.00,   0.00,  90.00,   52.00,  29.12,  90.00,   29.12,  52.00,  90.00,    0.00,  52.00,  90.00,
 54.00,   0.00,  90.00,   54.00,  30.24,  90.00,   30.24,  54.00,  90.00,    0.00,  54.00,  90.00,
 56.00,   0.00,  90.00,   56.00,  31.36,  90.00,   31.36,  56.00,  90.00,    0.00,  56.00,  90.00,
],[
  0.00,  50.00,  90.00,  -28.00,  50.00,  90.00,  -50.00,  28.00,  90.00,  -50.00,   0.00,  90.00,
  0.00,  52.00,  90.00,  -29.12,  52.00,  90.00,  -52.00,  29.12,  90.00,  -52.00,   0.00,  90.00,
  0.00,  54.00,  90.00,  -30.24,  54.00,  90.00,  -54.00,  30.24,  90.00,  -54.00,   0.00,  90.00,
  0.00,  56.00,  90.00,  -31.36,  56.00,  90.00,  -56.00,  31.36,  90.00,  -56.00,   0.00,  90.00,
],[
 -50.00,   0.00,  90.00,  -50.00, -28.00,  90.00,  -28.00, -50.00,  90.00,    0.00, -50.00,  90.00,
 -52.00,   0.00,  90.00,  -52.00, -29.12,  90.00,  -29.12, -52.00,  90.00,    0.00, -52.00,  90.00,
 -54.00,   0.00,  90.00,  -54.00, -30.24,  90.00,  -30.24, -54.00,  90.00,    0.00, -54.00,  90.00,
 -56.00,   0.00,  90.00,  -56.00, -31.36,  90.00,  -31.36, -56.00,  90.00,    0.00, -56.00,  90.00,
],[
  0.00, -50.00,  90.00,   28.00, -50.00,  90.00,   50.00, -28.00,  90.00,   50.00,   0.00,  90.00,
  0.00, -52.00,  90.00,   29.12, -52.00,  90.00,   52.00, -29.12,  90.00,   52.00,   0.00,  90.00,
  0.00, -54.00,  90.00,   30.24, -54.00,  90.00,   54.00, -30.24,  90.00,   54.00,   0.00,  90.00,
  0.00, -56.00,  90.00,   31.36, -56.00,  90.00,   56.00, -31.36,  90.00,   56.00,   0.00,  90.00,
],[
  8.00,   0.00, 102.00,    8.00,   4.48, 102.00,    4.48,   8.00, 102.00,    0.00,   8.00, 102.00,
 16.00,   0.00,  96.00,   16.00,   8.96,  96.00,    8.96,  16.00,  96.00,    0.00,  16.00,  96.00,
 52.00,   0.00,  96.00,   52.00,  29.12,  96.00,   29.12,  52.00,  96.00,    0.00,  52.00,  96.00,
 52.00,   0.00,  90.00,   52.00,  29.12,  90.00,   29.12,  52.00,  90.00,    0.00,  52.00,  90.00,
],[ // 25
  0.00,   8.00, 102.00,   -4.48,   8.00, 102.00,   -8.00,   4.48, 102.00,   -8.00,   0.00, 102.00,
  0.00,  16.00,  96.00,   -8.96,  16.00,  96.00,  -16.00,   8.96,  96.00,  -16.00,   0.00,  96.00,
  0.00,  52.00,  96.00,  -29.12,  52.00,  96.00,  -52.00,  29.12,  96.00,  -52.00,   0.00,  96.00,
  0.00,  52.00,  90.00,  -29.12,  52.00,  90.00,  -52.00,  29.12,  90.00,  -52.00,   0.00,  90.00,
],[
 -8.00,   0.00, 102.00,   -8.00,  -4.48, 102.00,   -4.48,  -8.00, 102.00,    0.00,  -8.00, 102.00,
 -16.00,   0.00,  96.00,  -16.00,  -8.96,  96.00,   -8.96, -16.00,  96.00,    0.00, -16.00,  96.00,
 -52.00,   0.00,  96.00,  -52.00, -29.12,  96.00,  -29.12, -52.00,  96.00,    0.00, -52.00,  96.00,
 -52.00,   0.00,  90.00,  -52.00, -29.12,  90.00,  -29.12, -52.00,  90.00,    0.00, -52.00,  90.00,
],[
  0.00,  -8.00, 102.00,    4.48,  -8.00, 102.00,    8.00,  -4.48, 102.00,    8.00,   0.00, 102.00,
  0.00, -16.00,  96.00,    8.96, -16.00,  96.00,   16.00,  -8.96,  96.00,   16.00,   0.00,  96.00,
  0.00, -52.00,  96.00,   29.12, -52.00,  96.00,   52.00, -29.12,  96.00,   52.00,   0.00,  96.00,
  0.00, -52.00,  90.00,   29.12, -52.00,  90.00,   52.00, -29.12,  90.00,   52.00,   0.00,  90.00,
],[
  0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,
 32.00,   0.00, 120.00,   32.00,  18.00, 120.00,   18.00,  32.00, 120.00,    0.00,  32.00, 120.00,
  0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,
  8.00,   0.00, 102.00,    8.00,   4.48, 102.00,    4.48,   8.00, 102.00,    0.00,   8.00, 102.00,
],[
  0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,
  0.00,  32.00, 120.00,  -18.00,  32.00, 120.00,  -32.00,  18.00, 120.00,  -32.00,   0.00, 120.00,
  0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,
  0.00,   8.00, 102.00,   -4.48,   8.00, 102.00,   -8.00,   4.48, 102.00,   -8.00,   0.00, 102.00,
],[ // 30
  0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,
 -32.00,   0.00, 120.00,  -32.00, -18.00, 120.00,  -18.00, -32.00, 120.00,    0.00, -32.00, 120.00,
  0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,
 -8.00,   0.00, 102.00,   -8.00,  -4.48, 102.00,   -4.48,  -8.00, 102.00,    0.00,  -8.00, 102.00,
],[
  0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,    0.00,   0.00, 120.00,
  0.00, -32.00, 120.00,   18.00, -32.00, 120.00,   32.00, -18.00, 120.00,   32.00,   0.00, 120.00,
  0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,    0.00,   0.00, 108.00,
  0.00,  -8.00, 102.00,    4.48,  -8.00, 102.00,    8.00,  -4.48, 102.00,    8.00,   0.00, 102.00,
]
];