Tuesday, October 25, 2011

yoshimura+tensegrity script

clear
% input dimension of radius, height, angle
% matrix dimensions [r,h,theta]
% theta yoshimura=60; tensegrity=158
dim=[4,6,158];
r=dim(1);
h=dim(2);
theta=dim(3)*pi/180; % from grad to rad!
sin0=sin(theta);
cos0=cos(theta);
sin1=sin(theta + 2*pi/3);
cos1=cos(theta + 2*pi/3);
sin2=sin(theta - 2*pi/3);
cos2=cos(theta - 2*pi/3);
coord=r*[1 0 0; -0.5 sqrt(3)/2 0; -0.5 -sqrt(3)/2 0; cos0 sin0 h/r; cos1 sin1 h/r; cos2 sin2 h/r];
% yoshimura pattern - theta=60
% conn=[1 2; 2 3; 3 1; 4 5; 5 6; 6 4; 1 4; 2 5; 3 6; 1 6; 2 4; 3 5];
% tensegrity pattern - theta=158
conn=[1 2; 2 3; 3 1; 4 5; 5 6; 6 4; 1 4; 2 5; 3 6; 1 6; 2 4; 3 5];
nElements=size(conn,1);
hold on
for e=1:nElements;
x=coord(conn(e,:), 1);
y=coord(conn(e,:), 2);
z=coord(conn(e,:), 3);
axis equal
plot3(x,y,z,'r-o');
% plot3(x,y,z,'r-o','LineWidth',3)
end