MATLAB
504030
20
10z [ ]5040
z [ ]y [ ]03020
10x[ ]-500x[ ]50-50-40-30-20-100x[ ]1020304050
%
n=4; %------
H=60; %------
h=H*0.5;%-----
R1=50;
R2=60;
phi=3*pi/n; %------
end
N=[N1 N2 N3];
[nr nc]=size(N);
for i=1:nc
plot3(N(1,i),N(2,i),N(3,i),'o');
hold on
end
xlabel('x[ ]'); ylabel('y[ ]'); zlabel('z[ ]');
%---B---
CB=[-eye(n) eye(n) zeros(n,n);zeros(n,n) -eye(n) eye(n);-eye(n) zeros(n,n) eye(n)]; CBT=CB';
B=N*CBT;
[nbr nbc]=size(CBT);
for i=1:nbc;
CBTi=CBT(:,i);
n1n=find(~(CBTi+ones(nbr,1)));
n1=N(:,n1n); n2=N(:,n1n)+B(:,i);
g_b=line([n1(1) n2(1)],[n1(2) n2(2)],[n1(3) n2(3)]); set([g_b],'LineWidth',3,'color','b');
hold on;
end
%---S---
end
e1=[e1;e1i];
end
for i=1:n
if i==1
e2i=[zeros(1,n-2) 1 0];
elseif i==2
e2i=[zeros(1,n-1) 1];
elseif i>2
e2i=[zeros(1,i-3) 1 zeros(1,n-i+2)]; end
e2=[e2;e2i];
end
for i=0:n-1
if i
e3i=[zeros(1,i) -1 1 zeros(1,n-i-2)]; elseif i==n-1
e3i=[1 zeros(1,n-2) -1];
end
e3=[e3;e3i];
end
CS1=[e3 zeros(n,2*n);zeros(n,2*n) e3];
CS2=[e1 -eye(n) zeros(n,n);-eye(n) e2 zeros(n,n)]; CS3=[zeros(n,n) e1 -eye(n);zeros(n,n) -eye(n) e2]; CS=[CS1;CS2;CS3];
CST=CS';
S=N*CST;
[nsr nsc]=size(CST);
for i=1:nsc;
CSTi=CST(:,i);
n2n=find(~(CSTi+ones(nsr,1)));
n1=N(:,n2n); n2=N(:,n2n)+S(:,i);
s_b=line([n1(1) n2(1)],[n1(2) n2(2)],[n1(3) n2(3)]); set([s_b],'LineWidth',1,'color','r');
hold on;
end
axis equal
MATLAB
504030
20
10z [ ]5040
z [ ]y [ ]03020
10x[ ]-500x[ ]50-50-40-30-20-100x[ ]1020304050
%
n=4; %------
H=60; %------
h=H*0.5;%-----
R1=50;
R2=60;
phi=3*pi/n; %------
end
N=[N1 N2 N3];
[nr nc]=size(N);
for i=1:nc
plot3(N(1,i),N(2,i),N(3,i),'o');
hold on
end
xlabel('x[ ]'); ylabel('y[ ]'); zlabel('z[ ]');
%---B---
CB=[-eye(n) eye(n) zeros(n,n);zeros(n,n) -eye(n) eye(n);-eye(n) zeros(n,n) eye(n)]; CBT=CB';
B=N*CBT;
[nbr nbc]=size(CBT);
for i=1:nbc;
CBTi=CBT(:,i);
n1n=find(~(CBTi+ones(nbr,1)));
n1=N(:,n1n); n2=N(:,n1n)+B(:,i);
g_b=line([n1(1) n2(1)],[n1(2) n2(2)],[n1(3) n2(3)]); set([g_b],'LineWidth',3,'color','b');
hold on;
end
%---S---
end
e1=[e1;e1i];
end
for i=1:n
if i==1
e2i=[zeros(1,n-2) 1 0];
elseif i==2
e2i=[zeros(1,n-1) 1];
elseif i>2
e2i=[zeros(1,i-3) 1 zeros(1,n-i+2)]; end
e2=[e2;e2i];
end
for i=0:n-1
if i
e3i=[zeros(1,i) -1 1 zeros(1,n-i-2)]; elseif i==n-1
e3i=[1 zeros(1,n-2) -1];
end
e3=[e3;e3i];
end
CS1=[e3 zeros(n,2*n);zeros(n,2*n) e3];
CS2=[e1 -eye(n) zeros(n,n);-eye(n) e2 zeros(n,n)]; CS3=[zeros(n,n) e1 -eye(n);zeros(n,n) -eye(n) e2]; CS=[CS1;CS2;CS3];
CST=CS';
S=N*CST;
[nsr nsc]=size(CST);
for i=1:nsc;
CSTi=CST(:,i);
n2n=find(~(CSTi+ones(nsr,1)));
n1=N(:,n2n); n2=N(:,n2n)+S(:,i);
s_b=line([n1(1) n2(1)],[n1(2) n2(2)],[n1(3) n2(3)]); set([s_b],'LineWidth',1,'color','r');
hold on;
end
axis equal