function sequence

%param1 = [7 .2 1.7 1.7 1 1; 7 .2 1.7 1.7 1 1]
%param2 = [6 1 1 1 1 1; 3 1 1 1 1 1]
%fname = 'example1.jpg'
%param2 is cool

%param1 = [8 1 1 3 1 1; 2 2 1.7 1.7 1 1]
%param2 = [5 .1 1.7 1.7 1 1; 1 .3 .5 .5 1 1]
%fname = 'example2.jpg'
%param1 = [5.6 0.28 1.56 1.96 1 1; 1.2 0.64 0.74 0.74 1 1] is cool

%param1 = [5 3.3 .2 4 1 1; 3 10 .1 2.5 1 1]
%param2 = [1 2 3  4 1 1; 3.7 4.5 4 50 1 1]
%fname = 'example3.jpg'

%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'example4.jpg'
%param2 is cool

%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 1 1; 9 9 9 9 1 1]
%fname = 'example5.jpg'

%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [-1 1 1 1 1 1; -1 1 1 1 1 1]
%fname = 'example6.jpg'
%interesting - object largest z direction when m iss closer to 0

%param1 = [.04 1.7 1.7 5.2 1 1; 1 1 1 0 1 1]
%param2 = [37.41 -.24 19.07 1 1.1 1.88; 100 100 100 4 1 1]
%fname = 'example7.jpg'
%param2 is a cool shape

%param1 = [37.41 -.24 19.07 1 1.1 1.88; 100 100 100 4 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'good1.jpg'

%param1 = [6 1 1 1 1 1; 3 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'good2.jpg'

%param1 = [6 1 1 1 1 1; 3 1 1 1 1 1]
%param2 = [37.41 -.24 19.07 1 1.1 1.88; 100 100 100 4 1 1]
%fname = 'ok1.jpg'
%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'example4.jpg'
%param1 = [5.6 0.28 1.56 1.96 1 1; 1.2 0.64 0.74 0.74 1 1]
%param2 = [1 2 3  4 1 1; 3.7 4.5 4 50 1 1]
%fname = 'good3.jpg'

%param1 = [5.6 0.28 1.56 1.96 1 1; 1.2 0.64 0.74 0.74 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'ok2.jpg'

%param1 = [7.4 7.6 7.8 8 7.4 7.4; 7.94 8.1 8 17.2 7.4 7.4]
%param2 = [8.282 1.552 6.214 3.4 1.02 1.176; 22.96 23.6 23.2 40.8 1 1]
%fname = 'good4.jpg'

%param1 = [5.6 0.28 1.56 1.96 1 1; 1.2 0.64 0.74 0.74 1 1]
%param2 = [7.4 7.6 7.8 8 7.4 7.4; 7.94 8.1 8 17.2 7.4 7.4]
%fname = 'ok3.jpg'%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'example4.jpg'

%param1 = [1 2 3  4 1 1; 3.7 4.5 4 50 1 1]
%param2 = [8.282 1.552 6.214 3.4 1.02 1.176; 22.96 23.6 23.2 40.8 1 1]
%fname = 'good5.jpg'
%good intermediate pictures

%param1 = [6 1 1 1 1 1; 3 1 1 1 1 1]
%hexagon flat star
%param1 = [5.6 0.28 1.56 1.96 1 1; 1.2 0.64 0.74 0.74 1 1]
%pointy thing%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'example4.jpg'
%param1 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%edge star pointy thing, weird
%param1 = [37.41 -.24 19.07 1 1.1 1.88; 100 100 100 4 1 1]
%cylinder-ish
%param1 = [1 2 3  4 1 1; 3.7 4.5 4 50 1 1]
%cone
%param2 = [7.4 7.6 7.8 8 7.4 7.4; 7.94 8.1 8 17.2 7.4 7.4]
%pointy star
%param2 = [8.282 1.552 6.214 3.4 1.02 1.176; 22.96 23.6 23.2 40.8 1 1]
%fname = 'example8.jpg'

%3 leaf object cone
%param1 = [6 .765 52.27 -0.202 1 1; 5 37.65 0.523 -18.99 1 1]
%triangular-ish prism
%param2 = [6 60 55 1000 1 1; 6 250 100 100 1 1]
%revolving doors
%param3 = [4 .17 -.61 -.66 0.1 0.24; 5 8.83 -.81 87.44 1.14 1.83]
%circular disk
%param4 = [321 4321 0.325 -4 .26 .%param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
%param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]
%fname = 'example4.jpg'78; -3 65.43 -453 0.987 1 73]
%snail type of thing
%param5 = [0.6000   -1.2640   -6.2880    7.8720    4.4800    6.7920;
%0.2000   -0.9360   -1.4480   82.9520    2.1120    7.2640]
%neg = [1 -1 1 1 1 1; -1 1 -1 -1 1 1;aram2 = [8.282 1.552 6.214 3.4 1.02 1.176; 22.96 23.6 23.2 40.8 1 1] 0 0 1 0 0 0; 0 0 0 -1 0 0; 0 0 0 0 1 0; 0 0 0 0 0 1]
%param1 = 10 * rand(2, 6) * neg
%param2 = 10 * rand(2, 6) * neg
%param3 = 10 * rand(2, 6) * neg
%param4 = 10 * rand(2, 6) * neg
%param5 = 10 * rand(2, 6) * neg

%drawseq(param1, param2);
%print('-djpeg', 'e1.jpg');

%drawseq(param3, param4);
%print('-djpeg', 'e7.jpg');
%drawseq(param2, param4);
%print('-djpeg', 'e5.jpg');

%parama = rand(1,4) * 10;
%paramb = rand(1,4) * 10;
%paramc = rand(1,4) * 10;
%paramd = rand(1,4) * 10;
%param1 = [parama 1 1; paramb 1 1]
%param2 = [paramc 1 1; paramd 1 1]

param1 = [1 1 1 1 1 1; 1 1 1 1 1 1]
param2 = [9 9 9 9 9 9; 9 9 9 9 9 9]

parama = 0.2*param1 + 0.8*param2
paramb = 0.4*param1 + 0.6*param2
paramc = 0.6*param1 + 0.4*param2
paramd = 0.8*param1 + 0.2*param2

%drawseq(param1, param2);
%print('-djpeg', 'r17.jpg');

end

function drawseq(param1, param2)
% param: 2*6 matrix, [m,n1,n2,n3,a,b (for r1); m,n1,n2,n3,a,b (for r2)]

counter = 1;
for t=0:0.2:1,

	delta = 0.05;
	d = -1:delta:1;
	[x0,y0,z0] = meshgrid(d,d,d);

	theta = atan(y0./x0) + (x0<0).*pi;
	phi = atan(z0./sqrt(x0.^2+y0.^2));

	param = t*param1 + (1-t)*param2;

	m = param(1,1); n1 = param(1,2); n2 = param(1,3); n3 = param(1,4); a = param(1,5); b = param(1,6);
	r1 = (abs(cos(m/4*theta)/a).^n2 + abs(sin(m/4*theta)/b).^n3).^(-1/n1);

	m = param(2,1); n1 = param(2,2); n2 = param(2,3); n3 = param(2,4); a = param(2,5); b = param(2,6);
	r2 = (abs(cos(m/4*phi)/a).^n2 + abs(sin(m/4*phi)/b).^n3).^(-1/n1);

	r = r1.*r2;

	v0 = r./max(max(max(r))) - sqrt(x0.^2+y0.^2+z0.^2);


	subplot(2,3,counter); counter=counter+1;
	p = patch(isosurface(x0,y0,z0,v0,0)); 
	set(p,'FaceColor','red','EdgeColor','none','AmbientStrength',.2,'SpecularStrength',.7,'DiffuseStrength',.4);
	isonormals(x0,y0,z0,v0,p); 
	colordef white
	daspect([1 1 1]);
	axis off
	view(3); 
	camlight right; 
	camlight left; 
	lighting phong;

end
end
