xcord=[0 1 0 0 1 1 0 1];
ycord=[0 0 1 0 1 0 1 1];
zcord=[0 0 0 1 0 1 1 1];
figure;
unitcell = scatter3(xcord(:), ycord(:), zcord(:),100,'fill','b');
plotLinesTheStupidWay(xcord, ycord, zcord);
axis([-1 1 -1 1 -1 1]*1.5)
xlabel('x')
ylabel('y')
zlabel('z')
angleStepSize = 1;
pos = [xcord; ycord; zcord];
for i = 0:angleStepSize:360
theta = i;
rotX = [1, 0, 0; 0, cosd(theta), -sind(theta); 0, sind(theta), cosd(theta)];
for j = 1:length(xcord)
foo = rotX*pos(:,j);
xcord(j) = foo(1);
ycord(j) = foo(2);
zcord(j) = foo(3);
end
unitcell = scatter3(xcord(:), ycord(:), zcord(:),100,'fill','b');
plotLinesTheStupidWay(xcord, ycord, zcord)
axis([-1 1 -1 1 -1 1]*1.5)
pause(0.1);
end
function plotLinesTheStupidWay(xcord, ycord, zcord)
hold on;
plot3([xcord(1), xcord(2)], [ycord(1), ycord(2)], [zcord(1), zcord(2)], '-r');
plot3([xcord(1), xcord(3)], [ycord(1), ycord(3)], [zcord(1), zcord(3)], '-r');
plot3([xcord(1), xcord(4)], [ycord(1), ycord(4)], [zcord(1), zcord(4)], '-r');
plot3([xcord(2), xcord(5)], [ycord(2), ycord(5)], [zcord(2), zcord(5)], '-r');
plot3([xcord(2), xcord(6)], [ycord(2), ycord(6)], [zcord(2), zcord(6)], '-r');
plot3([xcord(3), xcord(7)], [ycord(3), ycord(7)], [zcord(3), zcord(7)], '-r');
plot3([xcord(3), xcord(5)], [ycord(3), ycord(5)], [zcord(3), zcord(5)], '-r');
plot3([xcord(5), xcord(8)], [ycord(5), ycord(8)], [zcord(5), zcord(8)], '-r');
plot3([xcord(8), xcord(6)], [ycord(8), ycord(6)], [zcord(8), zcord(6)], '-r');
plot3([xcord(8), xcord(7)], [ycord(8), ycord(7)], [zcord(8), zcord(7)], '-r');
plot3([xcord(4), xcord(6)], [ycord(4), ycord(6)], [zcord(4), zcord(6)], '-r');
plot3([xcord(4), xcord(6)], [ycord(4), ycord(6)], [zcord(4), zcord(6)], '-r');
plot3([xcord(4), xcord(7)], [ycord(4), ycord(7)], [zcord(4), zcord(7)], '-r');
hold off
end
Best Answer