%  sierp3c(N) displays the N'th step in the generation of the fractal
%  known as the Sierpinski arrowhead, using color interpolation.
%  sierp3c(0) displays a tetrahedron; sierp3c(1) displays four smaller
%  tetrahedra left when you remove the "middle" of a larger one; etc.
%
%  sierp3c interpolates the colors of the tetrahedra between the four
%  vertices.  The vertices are colored white, red, green and blue.
%
%  See also sierp3.



% "sierp3c.m" written by Albert Dvornik <bert@mit.edu>
% Redistribute freely, but it would be nice to let me know if you use it.


function [] = sierp3c(n)

%%% calculate coordinates of the vertices
x = [0, 1, 1/2,       1/2      ];
y = [0, 0, sqrt(3)/2, sqrt(3)/6];
z = [0, 0, 0,         sqrt(2/3)];

%%% set window parameters
clf;
view(viewmtx(45,-7,35));
set(gca,'Visible','off');
colormap([]);

%%% call the "helper" procedure and select the color map
sierpiterc(x,y,z,n,[1,0,0,1],[0,1,0,1],[0,0,1,1]);
