%%%%%%%%%%%%%%%%
%clean up.
%%%%%%%%%%%%%%%%

clear;

%%%%%%%%%%%%%%%%
% select what kind of transform, 010 or 110
%%%%%%%%%%%%%%%%
%S = {'010', '110'};
%[Selection,ok] = listdlg('ListString',S,'SelectionMode','single');
Selection = 2;
%%%%%%%%%%%%%%%%
%set what is the result of press or stratch
%%%%%%%%%%%%%%%%

inputCell = inputdlg({'Please input the end of transform'}, 'Input',1,{'0.6'});
delta = str2num(inputCell{1});
%%%%%%%%%%%%%%%%
%set original points
%%%%%%%%%%%%%%%%
p0 = [0,0,0];
p1 = [1,0,0];
p2 = [0,0,1];
p3 = [0,1,0];
p4 = [1,1,0];
p5 = [0,1,1];
p6 = [1,0,1];
p7 = [ 1,1,1];
origin = [  %p0;p2;
            %p0;p3;
            %p0;p1;
            p4;p1;
            p6;p2;
            p6;p7;
            p4;p7;
            p5;p2;
            p5;p3;
            p4
        ];
origin0 = [ p0;p2;p0;p3;p0;p1 ];
%%%%%%%%%%%%%%%%
%transformation matrix in the direction of <010>
%%%%%%%%%%%%%%%%

transform010 =[ [ sqrt( 1 / delta ), 0 , 0]; [ 0,sqrt( 1 / delta ), 0 ]; [ 0, 0, delta ] ];

%%%%%%%%%%%%%%%%
% transformation matrix in the direction of <110>
%%%%%%%%%%%%%%%%

transform110 = [ [ ( 1 / delta + delta ) / 2, ( -1 / delta + delta ) / 2, 0 ];
                 [ ( -1 / delta + delta ) / 2, ( 1 / delta + delta ) / 2, 0 ];
                 [0,0,1]
             ];

%%%%%%%%%%%%%%%%
% do transform
%%%%%%%%%%%%%%%%

if( 1 == Selection  )
	result = origin * transform010;
    result0 = origin0 * transform010;
	
else 
	result = origin * transform110;
    result0 = origin0 * transform110;
end;

%%%%%%%%%%%%%%%
% draw picture
%%%%%%%%%%%%%%%

x = result(:,1);
y = result(:,2);
z = result(:,3);
h = line(x, y, z,'color','black','LineWidth',2);
x0 = result0(:,1);
y0 = result0(:,2);
z0 = result0(:,3);
line(x0, y0,z0, 'color','black','LineWidth',1,'LineStyle','-.');
grid on;
axis equal;
%xlabel('110');
%ylabel('-110');
%zlabel('001');
view( [0, 90, 0] );