#
# This file existance is justified to demonstrate loops:
#

#
# This loop uses the beep function to generate tones in different frequency
# and time. Unix systems does not support it.
#

step = 10;

save_mat = view_mat;

b = box(vector(-0.5, -0.2, -0.1), 1, 0.4, 0.2);

rotstepx = rotx(step);
rotstepy = roty(step);
rotstepz = rotz(step);

#
# Rotate around	the X axis:
#
for ( a = 1, 1, 360 / step,
	view_mat = rotstepx * view_mat:
	view(list(view_mat,b,axes), on)
    );


#
# Rotate around	the Y axis:
#
for ( a = 1, 1, 360 / step,
	view_mat = rotstepy * view_mat:
	view(list(view_mat,b,axes), on)
    );


#
# Rotate around	the Z axis:
#
for ( a = 1, 1, 360 / step,
        view_mat = rotstepz * view_mat:
	view(list(view_mat,b,axes), on)
    );

free(rotstepx); free(rotstepy); free(rotstepz);

#
# Direct use of homomat to create perspective views.
#
for ( a = 1, 1, 720 / step,
	view_mat = save_mat *
		   homomat( list( list( 1, 0, 0, 0 ),
				  list( 0, 1, 0, 0 ),
				  list( 0, 0, 1, -a*step/500 ),
				  list( 0, 0, a*step/500, 1 ) ) ):
	view(list(view_mat,b,axes), on)
    );
view_mat = save_mat;
view(list(view_mat), 0);
#
# Direct use of homomat to create shear effects.
#
shearb = b;
for ( a = 1, 1, 360 / step,
	shearb = b * homomat( list( list( 1, a*step/360, 0, 0 ),
				    list( 0, 1, 0, 0 ),
				    list( 0, 0, 1, 0 ),
				    list( 0, 0, 0, 1 ) ) ):
	view(list(shearb,axes), on)
    );
free(shearb);

view_mat = save_mat;
view(list(view_mat), 0);
