% compute angle and orthogonal direction for a given dislocation
% orientation on (-1 1 0) plane

b = [1 1 1]/2;
n = [-1 1 0];
m0 = cross(n,b);

%c_data = [2:10,15]; d_data = c_data+1;
c_data = [3:9,17]; d_data = c_data-1;

angle = zeros(size(c_data));

for i=1:length(c_data),
c=c_data(i);
d=d_data(i);
xi = c*[1 1 0] + d*[0 0 1];

%xi = [17 17 16];

m = cross(n,xi);
if sum(mod(m,2))==0
    m = m/2;
end
angle(i) = atan2(dot(xi,m0)/norm(m0),dot(xi,b)/norm(b)) * 180/pi;
    
rep_x = round(50/norm(m));
if (rep_x == 0)
    rep_x = 1;
end
rep_z = round(15/norm(xi));
if (rep_z == 0)
    rep_z = 1;
end


disp(sprintf('   set supercell(%.4g) " %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d"',...
     angle(i),m(1),m(2),m(3), rep_x, -1, 1, 0, 65, xi(1),xi(2),xi(3),rep_z));
end

s=' ';
for i=1:length(angle),
    s=[s, sprintf(' %6.4g',angle(i))];
end
disp(s);