Draw the Utah Teapot The Utah teapot, originally created by Martin Newell, is a convenient object for testing 3D graphics programs.

The task is to create a wireframe image of the teapot in perspective projection. To encourage the idea of a source-code application, the viewing and camera control may be isolated and excluded from the count. This is so the parameters and input file may be modified and the code re-used to generate diverse images, but it is not necessary to create a full-fledged utility that accepts complicated command-line arguments or such. A "hackerly" balance is sought.



ref. StackOverflow: How do Bezier Patches work in the Utah Teapot?

So there are three subtasks here:


read-in the teapot data in its original format.
subdivide the patch data using deCasteljau splitting or other method. Other methods are using Bezier basis matrices and evaluating the polynomials (standard refs, like Foley and van Dam, Newmann and Sproull), or Bernstein basis methods (which are still beyond me).
project the points to 2D (if the language does not support 3D natively) and draw the outline of each small patch as seen from an Eye point whose view is centered on a LookAt point and whose vertical axis is aligned with the vertical axis of the teapot (ie. draw it "upright" from a nice vantagepoint).


Assuming that reading line-oriented text data from a file is little trouble, this challenge is really about getting hands-on with Bi-Cubic Bezier patch data.

Since the simple normal test for backface culling is not sufficient (the patches are not all oriented outward), no hidden-line or -surface removal is necessary. As a wireframe, it should look just fine with the back visible. The appearance may be improved by adjusting the line-width depending upon the distance from the eye, but this is not strictly necessary (my own programs do not do this).

This is both code-golf and rosetta-stone. Answers competing in the golf should include a count as normal. But submissions in unusual languages are very much encouraged, even if they're not particularly short. 

For Kolmogorov-complexity enthusiasts, there is a more concise dataset where the full set may be reconstructed by adding rotations and mirroring of patches. And in Jim Blinn's A Trip Down the Graphics Pipeline, there is an even more concise method of generation by using the fact that the individual patches have rotational or other symmetries. The entire body (or lid) can be described by a single Bezier curve which is rotated around the y-axis. The spout and handles can be described by the two curves of their profile, and then selecting the intermediate control points to approximate a circular extrusion.
Postscript

Not fully golfed, but this illustrates a different approach than deCasteljau subdivision: evaluating the basis polynomial. Uses mat.ps.

(mat.ps)run[    % load matrix library, begin dictionary construction

/N 17
/C [ 0 7 4 ]   % Cam
/E [ 0 0 40 ] % Eye
/R 0 roty 120 rotx 90 rotz   % Rot: pan tilt twist
          matmul   matmul

/f(teapot)(r)file
/t{token pop exch pop}      % parse a number or other ps token
/s{(,){search not{t exit}if t 3 1 roll}loop}  % parse a comma-separated list
/r{token pop{[f 99 string readline pop s]}repeat}&gt;&gt;begin   % parse a count-prefixed paragraph of csv numbers
[/P[f r]/V[f r]/v{1 sub V exch get}        % Patches and Vertices and vert lookup shortcut
/B[[-1 3 -3 1][3 -6 3 0][-3 3 0 0][1 0 0 0]]              % Bezier basis matrix
/A{dup dup mul exch 2 copy mul 3 1 roll 1 4 array astore} % x-&gt;[x^3 x^2 x 1]
/M{[1 index 0 4 getinterval 2 index 4 4 getinterval       % flattened matrix-&gt;rowXcolumn matrix
3 index 8 4 getinterval 4 index 12 4 getinterval]exch pop}
/J{ C{sub}vop R matmul 0 get                              % perspective proJection  [x y z]-&gt;[X Y]
    aload pop E aload pop
    4 3 roll div exch neg
    4 3 roll add 1 index mul 4 1 roll
    3 1 roll sub mul}
&gt;&gt;begin

300 400 translate
1 14 dup dup scale div currentlinewidth mul setlinewidth  % global scale
/newline { /line {moveto /line {lineto} store} store } def
newline
P{
    8 dict begin
        [exch{v J 2 array astore}forall]/p exch def   % load patch vertices and project to 2D
        /X[p{0 get}forall] M B exch matmul B matmul def  % multiply control points by Bezier basis
        /Y[p{1 get}forall] M B exch matmul B matmul def

        0 1 N div 1 1 index .2 mul add{A/U exch def   % interpolate the polynomial over (u,v)/(N)
            /UX U X matmul def
            /UY U Y matmul def
            0 1 N div 1 1 index .2 mul add{A/V exch 1 array astore transpose def
                /UXV UX V matmul def
                /UYV UY V matmul def
                UXV 0 get 0 get
                UYV 0 get 0 get line
            }for
            newline
        }for

        0 1 N div 1 1 index .2 mul add{A/V exch def   % interpolate the polynomial over (u,v)/(N)
            /V [V] transpose def
            /XV X V matmul def
            /YV Y V matmul def
            0 1 N div 1 1 index .2 mul add{A/U exch 1 array astore transpose def
                /UXV U XV matmul def
                /UYV U YV matmul def
                UXV 0 get 0 get
                UYV 0 get 0 get line
            }for
            newline
        }for

    end

    %exit
}forall
stroke




1112

Stripping out the vertical lines, and discounting the parameters, yields
this 1112 char version. Uses mat.ps.

(mat.ps)run[    % 12

/N 17
/C [ 0 7 4 ]   % Cam 
/E [ 0 0 40 ] % Eye 
/R 0 roty 120 rotx 90 rotz   % Rot: pan tilt twist
          matmul   matmul

/f(teapot)(r)file/t{token pop exch pop}/s{(,){search not{t exit}if t   % 1100
3 1 roll}loop}/r{token pop{[f 99 string readline pop 
s]}repeat}&gt;&gt;begin[/P[f r]/V[f r]/v{1 sub 
V exch get}/B[[-1 3 -3 1][3 -6 3 0][-3 3 0 0][1 0 0 0]]/A{dup dup mul exch
2 copy mul 3 1 roll 1 4 array astore}/M{[1 index 0 4 getinterval 2 index 4 4 getinterval    
3 index 8 4 getinterval 4 index 12 4 getinterval]exch pop}/J{C{sub}vop R matmul 0 get    
aload pop E aload pop 4 3 roll div exch neg 4 3 roll add 1 index mul 4 1 roll
3 1 roll sub mul}&gt;&gt;begin 300 400 translate
1 14 dup dup scale div currentlinewidth mul setlinewidth  
/newline{/line{moveto/line{lineto}store}store}def newline
P{8 dict begin[exch{v J 2 array astore}forall]/p
exch def/X[p{0 get}forall] M B exch matmul B matmul
def/Y[p{1 get}forall] M B exch matmul B matmul def 
0 1 N div 1 1 index .2 mul add{A/U exch def/UX U X matmul def/UY U Y matmul def 
0 1 N div 1 1 index .2 mul add{A/V exch 1 array astore transpose
def/UXV UX V matmul def/UYV UY V matmul def UXV 0 get 0 get UYV 0 get 0 get line}for
newline}for end}forall stroke