Matlabで立方体表面のメッシュを作る。2枚ずつ作って組み合わせればいい。
N=50;
x1=linspace(-1,1,N);
y1=linspace(-1,1,N);
z1=linspace(-1,1,2);
x2=linspace(-1,1,N);
y2=linspace(-1,1,2);
z2=linspace(-1,1,N);
x3=linspace(-1,1,2);
y3=linspace(-1,1,N);
z3=linspace(-1,1,N);
count=1;
for i=1:1:length(x1)
for j=1:1:length(y1)
for k=1:1:length(z1)
X1(:,count)=[x1(i);y1(j);z1(k)];
count=count+1;
end
end
end
count=1;
for i=1:1:length(x2)
for j=1:1:length(y2)
for k=1:1:length(z2)
X2(:,count)=[x2(i);y2(j);z2(k)];
count=count+1;
end
end
end
count=1;
for i=1:1:length(x3)
for j=1:1:length(y3)
for k=1:1:length(z3)
X3(:,count)=[x3(i);y3(j);z3(k)];
count=count+1;
end
end
end
figure
plot3(X1(1,:),X1(2,:),X1(3,:),'ro')
hold on
plot3(X2(1,:),X2(2,:),X2(3,:),'go')
hold on
plot3(X3(1,:),X3(2,:),X3(3,:),'bo')
コメント