|
I have posted my code below. It is very long and not cleaned up at all...sorry. When the code is run, you should get an airplane. Now I have my shape and would like to find the distance from say one wing to the nose of the plane but the path needs to stay on the surface of the plane. The shape can change based on the input array p1 thru p7 and the other problem is that when the airplane is made, most of the shapes intersect so a lot of the vertices for a particular component are not necessarily on the outside of the plane. I am not required to make my shape this way but eventually, I will have to convert my code to C so the functions must be embedded matlab compatible. Any suggestions or comments are greatly appreciated. Thanks,
Meagan
p1=[1 1 3 1 1 5 0 90 0 0 0 1.01];
p2=[2 2 1 3 1 1 0 0 0 -4.5 0 1.01];
p3=[3 2 1 1 10 0.2 0 0 0 -2 0 1];
p4=[4 2 1 1.5 0.5 0.5 0 0 0 -2 3 1];
p5=[5 2 1 2 1 1 0 0 0 4.5 0 1.01];
p6=[6 2 1 1.5 0.5 0.5 0 0 0 -2 -3 1];
p7=[7 2 1 1 .2 2 0 30 0 5 0 2];
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p1(2)==1) %part ID 1=UnitCylinder
res=p1(3); %resolution
scalex=p1(4); %diameter of cylinder in x direction
scaley=p1(5); %diameter of cylinder in y direction
scalez=p1(6); %length of cylinder
rotx=p1(7); %rotation about x axis
roty=p1(8); %rotation about y axis
rotz=p1(9); %rotation about z axis
transx=p1(10); %translation in x direction
transy=p1(11); %translation in y direction
transz=p1(12); %translation in z direction
V1=cylinder.vertices;
V1=[V1(:,1)*scalex, V1(:,2)*scaley, V1(:,3)*scalez];
cylinder.vertices=V1;
a=rotz/57.29; %degrees to radians
V1=cylinder.vertices;
V1=[cos(a)*V1(:,1)-sin(a)*V1(:,2),sin(a)*V1(:,1)+cos(a)*V1(:,2),V1(:,3)];
cylinder.vertices=V1;
a=roty/57.29; %degrees to radians
V1=cylinder.vertices;
V1=[cos(a)*V1(:,1)+sin(a)*V1(:,3), V1(:,2), -sin(a)*V1(:,1)+cos(a)*V1(:,3)];
cylinder.vertices=V1;
a=rotx/57.29; %degrees to radians
V1=cylinder.vertices;
V1=[V1(:,1), cos(a)*V1(:,2)-sin(a)*V1(:,3), sin(a)*V1(:,2)+cos(a)*V1(:,3)];
cylinder.vertices=V1;
V1=cylinder.vertices;
V1=[V1(:,1)+transx, V1(:,2)+transy, V1(:,3)+transz];
cylinder.vertices=V1;
part1=cylinder;
elseif (p1(2)==2) %part ID 2=UnitSphere
res=p1(3); %resolution
scalex=p1(4); %diameter of sphere in x direction
scaley=p1(5); %diameter of sphere in y direction
scalez=p1(6); %diameter of sphere in z direction
rotx=p1(7); %rotation about x axis
roty=p1(8); %rotation about y axis
rotz=p1(9); %rotation about z axis
transx=p1(10); %translation in x direction
transy=p1(11); %translation in y direction
transz=p1(12); %translation in z direction
M1=sphere.vertices;
M1=[M1(:,1)*scalex, M1(:,2)*scaley, M1(:,3)*scalez];
sphere.vertices=M1;
a=rotz/57.29; %degrees to radians
M1=sphere.vertices;
M1=[cos(a)*M1(:,1)-sin(a)*M1(:,2),sin(a)*M1(:,1)+cos(a)*M1(:,2), M1(:,3)];
sphere.vertices=M1;
a=roty/57.29; %degrees to radians
M1=sphere.vertices;
M1=[cos(a)*M1(:,1)+sin(a)*M1(:,3), M1(:,2), -sin(a)*M1(:,1)+cos(a)*M1(:,3)];
sphere.vertices=M1;
a=rotx/57.29; %degrees to radians
M1=sphere.vertices;
M1=[M1(:,1), cos(a)*M1(:,2)-sin(a)*M1(:,3), sin(a)*M1(:,2)+cos(a)*M1(:,3)];
sphere.vertices=M1;
M1=sphere.vertices;
M1=[M1(:,1)+transx, M1(:,2)+transy, M1(:,3)+transz];
sphere.vertices=M1;
part1=sphere;
elseif (p1(2)==3) %part ID 3=UnitCube
res=p1(3); %resolution
scalex=p1(4); %length in x direction
scaley=p1(5); %length in y direction
scalez=p1(6); %length in z direction
rotx=p1(7); %rotation about x axis
roty=p1(8); %rotation about y axis
rotz=p1(9); %rotation about z axis
transx=p1(10); %translation in x direction
transy=p1(11); %translation in y direction
transz=p1(12); %translation in z direction
F1=cube.vertices;
F1=[F1(:,1)*scalex, F1(:,2)*scaley, F1(:,3)*scalez];
cube.vertices=F1;
a=rotz/57.29; %degrees to radians
F1=cube.vertices;
F1=[cos(a)*F1(:,1)-sin(a)*F1(:,2), sin(a)*F1(:,1)+cos(a)*F1(:,2), F1(:,3)];
cube.vertices=F1;
a=roty/57.29; %degrees to radians
F1=cube.vertices;
F1=[cos(a)*F1(:,1)+sin(a)*F1(:,3),F1(:,2), -sin(a)*F1(:,1)+cos(a)*F1(:,3)];
cube.vertices=F1;
a=rotx/57.29; %degrees to radians
F1=cube.vertices;
F1=[F(:,1),cos(a)*F1(:,2)-sin(a)*F1(:,3), sin(a)*F1(:,2)+cos(a)*F1(:,3)];
cube.vertices=F1;
F1=cube.vertices;
F1=[F1(:,1)+transx, F1(:,2)+transy, F1(:,3)+transz];
cube.vertices=F1;
part1=cube;
else
p1(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p2(2)==1) %part ID 1=UnitCylinder
res=p2(3); %resolution
scalex=p2(4); %diameter of cylinder in x direction
scaley=p2(5); %diameter of cylinder in y direction
scalez=p2(6); %length of cylinder
rotx=p2(7); %rotation about x axis
roty=p2(8); %rotation about y axis
rotz=p2(9); %rotation about z axis
transx=p2(10); %translation in x direction
transy=p2(11); %translation in y direction
transz=p2(12); %translation in z direction
V2=cylinder.vertices;
V2=[V2(:,1)*scalex, V2(:,2)*scaley, V2(:,3)*scalez];
cylinder.vertices=V2;
a=rotz/57.29; %degrees to radians
V2=cylinder.vertices;
V2=[cos(a)*V2(:,1)-sin(a)*V2(:,2), sin(a)*V(:,1)+cos(a)*V2(:,2), V2(:,3)];
cylinder.vertices=V2;
a=roty/57.29; %degrees to radians
V2=cylinder.vertices;
V2=[cos(a)*V2(:,1)+sin(a)*V2(:,3), V2(:,2), -sin(a)*V2(:,1)+cos(a)*V2(:,3)];
cylinder.vertices=V2;
a=rotx/57.29; %degrees to radians
V2=cylinder.vertices;
V2=[V(:,1), cos(a)*V2(:,2)-sin(a)*V2(:,3), sin(a)*V2(:,2)+cos(a)*V2(:,3)];
cylinder.vertices=V2;
V2=cylinder.vertices;
V2=[V2(:,1)+transx, V2(:,2)+transy, V2(:,3)+transz];
cylinder.vertices=V2;
part2=cylinder;
elseif (p2(2)==2) %part ID 2=UnitSphere
res=p2(3); %resolution
scalex=p2(4); %diameter of sphere in x direction
scaley=p2(5); %diameter of sphere in y direction
scalez=p2(6); %diameter of sphere in z direction
rotx=p2(7); %rotation about x axis
roty=p2(8); %rotation about y axis
rotz=p2(9); %rotation about z axis
transx=p2(10); %translation in x direction
transy=p2(11); %translation in y direction
transz=p2(12); %translation in z direction
M2=sphere.vertices;
M2=[M2(:,1)*scalex, M2(:,2)*scaley, M2(:,3)*scalez];
sphere.vertices=M2;
a=rotz/57.29; %degrees to radians
M2=sphere.vertices;
M2=[cos(a)*M2(:,1)-sin(a)*M2(:,2), sin(a)*M2(:,1)+cos(a)*M2(:,2), M2(:,3)];
sphere.vertices=M2;
a=roty/57.29; %degrees to radians
M2=sphere.vertices;
M2=[cos(a)*M2(:,1)+sin(a)*M2(:,3), M2(:,2), -sin(a)*M2(:,1)+cos(a)*M2(:,3)];
sphere.vertices=M2;
a=rotx/57.29; %degrees to radians
M2=sphere.vertices;
M2=[M2(:,1), cos(a)*M2(:,2)-sin(a)*M2(:,3), sin(a)*M2(:,2)+cos(a)*M2(:,3)];
sphere.vertices=M2;
M2=sphere.vertices;
M2=[M2(:,1)+transx, M2(:,2)+transy, M2(:,3)+transz];
sphere.vertices=M2;
part2=sphere;
elseif (p2(2)==3) %part ID 3=UnitCube
res=p2(3); %resolution
scalex=p2(4); %length in x direction
scaley=p2(5); %length in y direction
scalez=p2(6); %length in z direction
rotx=p2(7); %rotation about x axis
roty=p2(8); %rotation about y axis
rotz=p2(9); %rotation about z axis
transx=p2(10); %translation in x direction
transy=p2(11); %translation in y direction
transz=p2(12); %translation in z direction
F2=cube.vertices;
F2=[F2(:,1)*scalex, F2(:,2)*scaley, F2(:,3)*scalez];
cube.vertices=F2;
a=rotz/57.29; %degrees to radians
F2=cube.vertices;
F2=[cos(a)*F2(:,1)-sin(a)*F2(:,2), sin(a)*F2(:,1)+cos(a)*F2(:,2), F2(:,3)];
cube.vertices=F2;
a=roty/57.29; %degrees to radians
F2=cube.vertices;
F2=[cos(a)*F2(:,1)+sin(a)*F2(:,3), F2(:,2), -sin(a)*F2(:,1)+cos(a)*F2(:,3)];
cube.vertices=F2;
a=rotx/57.29; %degrees to radians
F2=cube.vertices;
F2=[F(:,1), cos(a)*F2(:,2)-sin(a)*F2(:,3),sin(a)*F2(:,2)+cos(a)*F2(:,3)];
cube.vertices=F2;
F2=cube.vertices;
F2=[F2(:,1)+transx, F2(:,2)+transy, F2(:,3)+transz];
cube.vertices=F2;
part2=cube;
else
p2(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p3(2)==1) %part ID 1=UnitCylinder
res=p3(3); %resolution
scalex=p3(4); %diameter of cylinder in x direction
scaley=p3(5); %diameter of cylinder in y direction
scalez=p3(6); %length of cylinder
rotx=p3(7); %rotation about x axis
roty=p3(8); %rotation about y axis
rotz=p3(9); %rotation about z axis
transx=p3(10); %translation in x direction
transy=p3(11); %translation in y direction
transz=p3(12); %translation in z direction
V3=cylinder.vertices;
V3=[V3(:,1)*scalex, V3(:,2)*scaley, V3(:,3)*scalez];
cylinder.vertices=V3;
a=rotz/57.29; %degrees to radians
V3=cylinder.vertices;
V3=[cos(a)*V3(:,1)-sin(a)*V3(:,2), sin(a)*V3(:,1)+cos(a)*V3(:,2),V3(:,3)];
cylinder.vertices=V3;
a=roty/57.29; %degrees to radians
V3=cylinder.vertices;
V3=[cos(a)*V3(:,1)+sin(a)*V3(:,3),V3(:,2), -sin(a)*V3(:,1)+cos(a)*V3(:,3)];
cylinder.vertices=V3;
a=rotx/57.29; %degrees to radians
V3=cylinder.vertices;
V3=[V3(:,1), cos(a)*V3(:,2)-sin(a)*V3(:,3), sin(a)*V3(:,2)+cos(a)*V3(:,3)];
cylinder.vertices=V3;
V3=cylinder.vertices;
V3=[V3(:,1)+transx, V3(:,2)+transy, V3(:,3)+transz];
cylinder.vertices=V3;
part3=cylinder;
elseif (p3(2)==2) %part ID 2=UnitSphere
res=p3(3); %resolution
scalex=p3(4); %diameter of sphere in x direction
scaley=p3(5); %diameter of sphere in y direction
scalez=p3(6); %diameter of sphere in z direction
rotx=p3(7); %rotation about x axis
roty=p3(8); %rotation about y axis
rotz=p3(9); %rotation about z axis
transx=p3(10); %translation in x direction
transy=p3(11); %translation in y direction
transz=p3(12); %translation in z direction
M3=sphere.vertices;
M3=[M3(:,1)*scalex, M3(:,2)*scaley, M3(:,3)*scalez];
sphere.vertices=M3;
a=rotz/57.29; %degrees to radians
M3=sphere.vertices;
M3=[cos(a)*M3(:,1)-sin(a)*M3(:,2),sin(a)*M3(:,1)+cos(a)*M3(:,2),M3(:,3)];
sphere.vertices=M3;
a=roty/57.29; %degrees to radians
M3=sphere.vertices;
M3=[cos(a)*M3(:,1)+sin(a)*M3(:,3),M3(:,2),-sin(a)*M3(:,1)+cos(a)*M3(:,3)];
sphere.vertices=M3;
a=rotx/57.29; %degrees to radians
M3=sphere.vertices;
M3=[M3(:,1), cos(a)*M3(:,2)-sin(a)*M3(:,3),sin(a)*M3(:,2)+cos(a)*M3(:,3)];
sphere.vertices=M3;
M3=sphere.vertices;
M3=[M3(:,1)+transx, M3(:,2)+transy, M3(:,3)+transz];
sphere.vertices=M3;
part3=sphere;
elseif (p3(2)==3) %part ID 3=UnitCube
res=p3(3); %resolution
scalex=p3(4); %length in x direction
scaley=p3(5); %length in y direction
scalez=p3(6); %length in z direction
rotx=p3(7); %rotation about x axis
roty=p3(8); %rotation about y axis
rotz=p3(9); %rotation about z axis
transx=p3(10); %translation in x direction
transy=p3(11); %translation in y direction
transz=p3(12); %translation in z direction
F3=cube.vertices;
F3=[F3(:,1)*scalex, F3(:,2)*scaley, F3(:,3)*scalez];
cube.vertices=F3;
a=rotz/57.29; %degrees to radians
F3=cube.vertices;
F3=[cos(a)*F3(:,1)-sin(a)*F3(:,2),sin(a)*F3(:,1)+cos(a)*F3(:,2),F3(:,3)];
cube.vertices=F3;
a=roty/57.29; %degrees to radians
F3=cube.vertices;
F3=[cos(a)*F3(:,1)+sin(a)*F3(:,3),F3(:,2), -sin(a)*F3(:,1)+cos(a)*F3(:,3)];
cube.vertices=F3;
a=rotx/57.29; %degrees to radians
F3=cube.vertices;
F3=[F3(:,1),cos(a)*F3(:,2)-sin(a)*F3(:,3),sin(a)*F3(:,2)+cos(a)*F3(:,3)];
cube.vertices=F3;
F3=cube.vertices;
F3=[F3(:,1)+transx, F3(:,2)+transy, F3(:,3)+transz];
cube.vertices=F3;
part3=cube;
else
p3(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0;0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p4(2)==1) %part ID 1=UnitCylinder
res=p4(3); %resolution
scalex=p4(4); %diameter of cylinder in x direction
scaley=p4(5); %diameter of cylinder in y direction
scalez=p4(6); %length of cylinder
rotx=p4(7); %rotation about x axis
roty=p4(8); %rotation about y axis
rotz=p4(9); %rotation about z axis
transx=p4(10); %translation in x direction
transy=p4(11); %translation in y direction
transz=p4(12); %translation in z direction
V4=cylinder.vertices;
V4=[V4(:,1)*scalex, V4(:,2)*scaley, V4(:,3)*scalez];
cylinder.vertices=V4;
a=rotz/57.29; %degrees to radians
V4=cylinder.vertices;
V4=[cos(a)*V4(:,1)-sin(a)*V4(:,2),sin(a)*V4(:,1)+cos(a)*V4(:,2),V4(:,3)];
cylinder.vertices=V4;
a=roty/57.29; %degrees to radians
V4=cylinder.vertices;
V4=[cos(a)*V4(:,1)+sin(a)*V4(:,3),V4(:,2), -sin(a)*V4(:,1)+cos(a)*V4(:,3)];
cylinder.vertices=V4;
a=rotx/57.29; %degrees to radians
V4=cylinder.vertices;
V4=[V4(:,1), cos(a)*V4(:,2)-sin(a)*V4(:,3), sin(a)*V4(:,2)+cos(a)*V4(:,3)];
cylinder.vertices=V4;
V4=cylinder.vertices;
V4=[V4(:,1)+transx, V4(:,2)+transy, V4(:,3)+transz];
cylinder.vertices=V4;
part4=cylinder;
elseif (p4(2)==2) %part ID 2=UnitSphere
res=p4(3); %resolution
scalex=p4(4); %diameter of sphere in x direction
scaley=p4(5); %diameter of sphere in y direction
scalez=p4(6); %diameter of sphere in z direction
rotx=p4(7); %rotation about x axis
roty=p4(8); %rotation about y axis
rotz=p4(9); %rotation about z axis
transx=p4(10); %translation in x direction
transy=p4(11); %translation in y direction
transz=p4(12); %translation in z direction
M4=sphere.vertices;
M4=[M4(:,1)*scalex, M4(:,2)*scaley, M4(:,3)*scalez];
sphere.vertices=M4;
a=rotz/57.29; %degrees to radians
M4=sphere.vertices;
M4=[cos(a)*M4(:,1)-sin(a)*M4(:,2),sin(a)*M4(:,1)+cos(a)*M4(:,2),M4(:,3)];
sphere.vertices=M4;
a=roty/57.29; %degrees to radians
M4=sphere.vertices;
M4=[cos(a)*M4(:,1)+sin(a)*M4(:,3), M4(:,2),-sin(a)*M4(:,1)+cos(a)*M4(:,3)];
sphere.vertices=M4;
a=rotx/57.29; %degrees to radians
M4=sphere.vertices;
M4=[M4(:,1), cos(a)*M4(:,2)-sin(a)*M4(:,3),sin(a)*M4(:,2)+cos(a)*M4(:,3)];
sphere.vertices=M4;
M4=sphere.vertices;
M4=[M4(:,1)+transx, M4(:,2)+transy, M4(:,3)+transz];
sphere.vertices=M4;
part4=sphere;
elseif (p4(2)==3) %part ID 3=UnitCube
res=p4(3); %resolution
scalex=p4(4); %length in x direction
scaley=p4(5); %length in y direction
scalez=p4(6); %length in z direction
rotx=p4(7); %rotation about x axis
roty=p4(8); %rotation about y axis
rotz=p4(9); %rotation about z axis
transx=p4(10); %translation in x direction
transy=p4(11); %translation in y direction
transz=p4(12); %translation in z direction
F4=cube.vertices;
F4=[F4(:,1)*scalex, F4(:,2)*scaley, F4(:,3)*scalez];
cube.vertices=F4;
a=rotz/57.29; %degrees to radians
F4=cube.vertices;
F4=[cos(a)*F4(:,1)-sin(a)*F4(:,2), sin(a)*F4(:,1)+cos(a)*F4(:,2),F4(:,3)];
cube.vertices=F4;
a=roty/57.29; %degrees to radians
F4=cube.vertices;
F4=[cos(a)*F4(:,1)+sin(a)*F4(:,3), F4(:,2), -sin(a)*F4(:,1)+cos(a)*F4(:,3)];
cube.vertices=F4;
a=rotx/57.29; %degrees to radians
F4=cube.vertices;
F4=[F4(:,1), cos(a)*F4(:,2)-sin(a)*F4(:,3), sin(a)*F4(:,2)+cos(a)*F4(:,3)];
cube.vertices=F4;
F4=cube.vertices;
F4=[F4(:,1)+transx, F4(:,2)+transy, F4(:,3)+transz];
cube.vertices=F4;
part4=cube;
else
p4(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p5(2)==1) %part ID 1=UnitCylinder
res=p5(3); %resolution
scalex=p5(4); %diameter of cylinder in x direction
scaley=p5(5); %diameter of cylinder in y direction
scalez=p5(6); %length of cylinder
rotx=p5(7); %rotation about x axis
roty=p5(8); %rotation about y axis
rotz=p5(9); %rotation about z axis
transx=p5(10); %translation in x direction
transy=p5(11); %translation in y direction
transz=p5(12); %translation in z direction
V5=cylinder.vertices;
V5=[V5(:,1)*scalex, V5(:,2)*scaley, V5(:,3)*scalez];
cylinder.vertices=V5;
a=rotz/57.29; %degrees to radians
V5=cylinder.vertices;
V5=[cos(a)*V5(:,1)-sin(a)*V5(:,2), sin(a)*V5(:,1)+cos(a)*V5(:,2),V5(:,3)];
cylinder.vertices=V5;
a=roty/57.29; %degrees to radians
V5=cylinder.vertices;
V5=[cos(a)*V5(:,1)+sin(a)*V5(:,3), V5(:,2), -sin(a)*V5(:,1)+cos(a)*V5(:,3)];
cylinder.vertices=V5;
a=rotx/57.29; %degrees to radians
V5=cylinder.vertices;
V5=[V5(:,1), cos(a)*V5(:,2)-sin(a)*V5(:,3), sin(a)*V5(:,2)+cos(a)*V5(:,3)];
cylinder.vertices=V5;
V5=cylinder.vertices;
V5=[V5(:,1)+transx, V5(:,2)+transy, V5(:,3)+transz];
cylinder.vertices=V5;
part5=cylinder;
elseif (p5(2)==2) %part ID 2=UnitSphere
res=p5(3); %resolution
scalex=p5(4); %diameter of sphere in x direction
scaley=p5(5); %diameter of sphere in y direction
scalez=p5(6); %diameter of sphere in z direction
rotx=p5(7); %rotation about x axis
roty=p5(8); %rotation about y axis
rotz=p5(9); %rotation about z axis
transx=p5(10); %translation in x direction
transy=p5(11); %translation in y direction
transz=p5(12); %translation in z direction
M5=sphere.vertices;
M5=[M5(:,1)*scalex, M5(:,2)*scaley, M5(:,3)*scalez];
sphere.vertices=M5;
a=rotz/57.29; %degrees to radians
M5=sphere.vertices;
M5=[cos(a)*M5(:,1)-sin(a)*M5(:,2), sin(a)*M5(:,1)+cos(a)*M5(:,2),M5(:,3)];
sphere.vertices=M5;
a=roty/57.29; %degrees to radians
M5=sphere.vertices;
M5=[cos(a)*M5(:,1)+sin(a)*M5(:,3), M5(:,2), -sin(a)*M5(:,1)+cos(a)*M5(:,3)];
sphere.vertices=M5;
a=rotx/57.29; %degrees to radians
M5=sphere.vertices;
M5=[M5(:,1), cos(a)*M5(:,2)-sin(a)*M5(:,3), sin(a)*M5(:,2)+cos(a)*M5(:,3)];
sphere.vertices=M5;
M5=sphere.vertices;
M5=[M5(:,1)+transx, M5(:,2)+transy, M5(:,3)+transz];
sphere.vertices=M5;
part5=sphere;
elseif (p5(2)==3) %part ID 3=UnitCube
res=p5(3); %resolution
scalex=p5(4); %length in x direction
scaley=p5(5); %length in y direction
scalez=p5(6); %length in z direction
rotx=p5(7); %rotation about x axis
roty=p5(8); %rotation about y axis
rotz=p5(9); %rotation about z axis
transx=p5(10); %translation in x direction
transy=p5(11); %translation in y direction
transz=p5(12); %translation in z direction
F5=cube.vertices;
F5=[F5(:,1)*scalex, F5(:,2)*scaley, F5(:,3)*scalez];
cube.vertices=F5;
a=rotz/57.29; %degrees to radians
F5=cube.vertices;
F5=[cos(a)*F5(:,1)-sin(a)*F5(:,2), sin(a)*F5(:,1)+cos(a)*F5(:,2), F5(:,3)];
cube.vertices=F5;
a=roty/57.29; %degrees to radians
F5=cube.vertices;
F5=[cos(a)*F5(:,1)+sin(a)*F5(:,3), F5(:,2), -sin(a)*F5(:,1)+cos(a)*F5(:,3)];
cube.vertices=F5;
a=rotx/57.29; %degrees to radians
F5=cube.vertices;
F5=[F5(:,1), cos(a)*F5(:,2)-sin(a)*F5(:,3), sin(a)*F5(:,2)+cos(a)*F5(:,3)];
cube.vertices=F5;
F5=cube.vertices;
F5=[F5(:,1)+transx, F5(:,2)+transy, F5(:,3)+transz];
cube.vertices=F5;
part5=cube;
else
p5(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p6(2)==1) %part ID 1=UnitCylinder
res=p6(3); %resolution
scalex=p6(4); %diameter of cylinder in x direction
scaley=p6(5); %diameter of cylinder in y direction
scalez=p6(6); %length of cylinder
rotx=p6(7); %rotation about x axis
roty=p6(8); %rotation about y axis
rotz=p6(9); %rotation about z axis
transx=p6(10); %translation in x direction
transy=p6(11); %translation in y direction
transz=p6(12); %translation in z direction
V6=cylinder.vertices;
V6=[V6(:,1)*scalex, V6(:,2)*scaley, V6(:,3)*scalez];
cylinder.vertices=V6;
a=rotz/57.29; %degrees to radians
V6=cylinder.vertices;
V6=[cos(a)*V6(:,1)-sin(a)*V6(:,2), sin(a)*V6(:,1)+cos(a)*V6(:,2),V6(:,3)];
cylinder.vertices=V6;
a=roty/57.29; %degrees to radians
V6=cylinder.vertices;
V6=[cos(a)*V6(:,1)+sin(a)*V6(:,3), V6(:,2), -sin(a)*V6(:,1)+cos(a)*V6(:,3)];
cylinder.vertices=V6;
a=rotx/57.29; %degrees to radians
V6=cylinder.vertices;
V6=[V6(:,1), cos(a)*V6(:,2)-sin(a)*V6(:,3), sin(a)*V6(:,2)+cos(a)*V6(:,3)];
cylinder.vertices=V6;
V6=cylinder.vertices;
V6=[V6(:,1)+transx, V6(:,2)+transy, V6(:,3)+transz];
cylinder.vertices=V6;
part6=cylinder;
elseif (p6(2)==2) %part ID 2=UnitSphere
res=p6(3); %resolution
scalex=p6(4); %diameter of sphere in x direction
scaley=p6(5); %diameter of sphere in y direction
scalez=p6(6); %diameter of sphere in z direction
rotx=p6(7); %rotation about x axis
roty=p6(8); %rotation about y axis
rotz=p6(9); %rotation about z axis
transx=p6(10); %translation in x direction
transy=p6(11); %translation in y direction
transz=p6(12); %translation in z direction
M6=sphere.vertices;
M6=[M6(:,1)*scalex, M6(:,2)*scaley, M6(:,3)*scalez];
sphere.vertices=M6;
a=rotz/57.29; %degrees to radians
M6=sphere.vertices;
M6=[cos(a)*M6(:,1)-sin(a)*M6(:,2), sin(a)*M6(:,1)+cos(a)*M6(:,2), M6(:,3)];
sphere.vertices=M6;
a=roty/57.29; %degrees to radians
M6=sphere.vertices;
M6=[cos(a)*M6(:,1)+sin(a)*M6(:,3), M6(:,2), -sin(a)*M6(:,1)+cos(a)*M6(:,3)];
sphere.vertices=M6;
a=rotx/57.29; %degrees to radians
M6=sphere.vertices;
M6=[M6(:,1), cos(a)*M6(:,2)-sin(a)*M6(:,3), sin(a)*M6(:,2)+cos(a)*M6(:,3)];
sphere.vertices=M6;
M6=sphere.vertices;
M6=[M6(:,1)+transx, M6(:,2)+transy, M6(:,3)+transz];
sphere.vertices=M6;
part6=sphere;
elseif (p6(2)==3) %part ID 3=UnitCube
res=p6(3); %resolution
scalex=p6(4); %length in x direction
scaley=p6(5); %length in y direction
scalez=p6(6); %length in z direction
rotx=p6(7); %rotation about x axis
roty=p6(8); %rotation about y axis
rotz=p6(9); %rotation about z axis
transx=p6(10); %translation in x direction
transy=p6(11); %translation in y direction
transz=p6(12); %translation in z direction
F6=cube.vertices;
F6=[F6(:,1)*scalex, F6(:,2)*scaley, F6(:,3)*scalez];
cube.vertices=F6;
a=rotz/57.29; %degrees to radians
F6=cube.vertices;
F6=[cos(a)*F6(:,1)-sin(a)*F6(:,2), sin(a)*F6(:,1)+cos(a)*F6(:,2), F6(:,3)];
cube.vertices=F6;
a=roty/57.29; %degrees to radians
F6=cube.vertices;
F6=[cos(a)*F6(:,1)+sin(a)*F6(:,3), F6(:,2), -sin(a)*F6(:,1)+cos(a)*F6(:,3)];
cube.vertices=F6;
a=rotx/57.29; %degrees to radians
F6=cube.vertices;
F6=[F6(:,1), cos(a)*F6(:,2)-sin(a)*F6(:,3), sin(a)*F6(:,2)+cos(a)*F6(:,3)];
cube.vertices=F6;
F6=cube.vertices;
F6=[F6(:,1)+transx, F6(:,2)+transy, F6(:,3)+transz];
cube.vertices=F6;
part6=cube;
else
p6(2)=0;
end
cube.vertices=[ 0 0 0; 1 0 0; 1 1 0; 0 1 0;0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
cube.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8; ] ;
cube.vertices = cube.vertices * 2 - 1;
cylinder.vertices=[-1,0,-1;-1,0,0;-0.500000000000000,-0.856380903262898,-1;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,-1;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,-1;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,-1;-0.500000000000000,0.856380903262898,0;0,-1,-1;0,-1,0;0,1,-1;0,1,0;0.500000000000000,-0.856380903262898,-1;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,-1;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,-1;0.856380903262898,-0.500000000000000,0;1,0,-1;1,0,0;0.856380903262898,0.500000000000000,-1;0.856380903262898,0.500000000000000,0;-1,0,1;-0.500000000000000,-0.856380903262898,1;-0.856380903262898,-0.500000000000000,1;-0.856380903262898,0.500000000000000,1;-0.500000000000000,0.856380903262898,1;0,-1,1;0,1,1;0.5000000000000
00,-0.856380903262898,1;0.500000000000000,0.856380903262898,1;0.856380903262898,-0.500000000000000,1;1,0,1;0.856380903262898,0.500000000000000,1;];
cylinder.faces=[3,4,5;5,4,6;5,6,1;1,6,2;1,2,7;7,2,8;7,8,9;9,8,10;11,12,3;3,12,4;9,10,13;13,10,14;11,15,12;12,15,16;17,13,18;18,13,14;15,19,16;16,19,20;19,21,20;20,21,22;21,23,22;22,23,24;23,17,24;24,17,18;4,26,6;6,26,27;6,27,2;2,27,25;2,25,8;8,25,28;8,28,10;10,28,29;12,30,4;4,30,26;10,29,14;14,29,31;12,16,30;30,16,32;18,14,33;33,14,31;16,20,32;32,20,34;20,22,34;34,22,35;22,24,35;35,24,36;24,18,36;36,18,33;];
sphere.vertices=[0,0,-1;-0.500000000000000,-0.500000000000000,-0.686740068930804;-0.500000000000000,-0.686740068930804,-0.500000000000000;-0.686740068930804,-0.500000000000000,-0.500000000000000;-0.500000000000000,0,-0.856380903262898;-0.856380903262898,0,-0.500000000000000;-0.500000000000000,0.500000000000000,-0.686740068930804;-0.686740068930804,0.500000000000000,-0.500000000000000;-0.500000000000000,0.686740068930805,-0.500000000000000;0,-0.500000000000000,-0.856380903262898;0,-0.856380903262898,-0.500000000000000;0,0.500000000000000,-0.856380903262898;0,0.856380903262898,-0.500000000000000;0.500000000000000,-0.500000000000000,-0.686740068930804;0.500000000000000,-0.686740068930804,-0.500000000000000;0.500000000000000,0,-0.856380903262898;0.500000000000000,0.500000000000000,-0.686740068930804;0.500000000000000,0.686740068930805,-0.500000000000000;0.686740068930805,-0.500000000000000,-
0.500000000000000;0.856380903262898,0,-0.500000000000000;0.686740068930805,0.500000000000000,-0.500000000000000;-1,0,0;-0.500000000000000,-0.856380903262898,0;-0.856380903262898,-0.500000000000000,0;-0.856380903262898,0.500000000000000,0;-0.500000000000000,0.856380903262898,0;0,-1,0;0,1,0;0.500000000000000,-0.856380903262898,0;0.500000000000000,0.856380903262898,0;0.856380903262898,-0.500000000000000,0;1,0,0;0.856380903262898,0.500000000000000,0;-0.500000000000000,-0.686740068930804,0.500000000000000;-0.686740068930804,-0.500000000000000,0.500000000000000;-0.856380903262898,0,0.500000000000000;-0.686740068930804,0.500000000000000,0.500000000000000;-0.500000000000000,0.686740068930805,0.500000000000000;0,-0.856380903262898,0.500000000000000;0,0.856380903262898,0.500000000000000;0.500000000000000,-0.686740068930804,0.500000000000000;0.500000000000000,0.686740068930805,0.500000000000000;0.6
86740068930805,-0.500000000000000,0.500000000000000;0.856380903262898,0,0.500000000000000;0.686740068930805,0.500000000000000,0.500000000000000;-0.500000000000000,-0.500000000000000,0.686740068930805;-0.500000000000000,0,0.856380903262898;-0.500000000000000,0.500000000000000,0.686740068930805;0,-0.500000000000000,0.856380903262898;0,0,1;0,0.500000000000000,0.856380903262898;0.500000000000000,-0.500000000000000,0.686740068930805;0.500000000000000,0,0.856380903262898;0.500000000000000,0.500000000000000,0.686740068930805;];
sphere.faces=[2,3,4;2,4,5;5,4,6;5,6,7;7,6,8;7,8,9;2,10,3;3,10,11;1,10,2;1,2,5;1,5,7;1,7,12;7,9,12;12,9,13;10,14,11;11,14,15;10,1,16;10,16,14;16,1,12;16,12,17;12,13,17;17,13,18;14,19,15;14,16,19;19,16,20;16,17,20;20,17,21;17,18,21;3,23,4;4,23,24;4,24,6;6,24,22;6,22,8;8,22,25;8,25,9;9,25,26;11,27,3;3,27,23;13,9,28;28,9,26;15,29,11;11,29,27;18,13,30;30,13,28;15,19,29;29,19,31;19,20,31;31,20,32;20,21,32;32,21,33;21,18,33;33,18,30;23,34,24;24,34,35;24,35,22;22,35,36;25,22,36;25,36,37;25,37,26;26,37,38;23,27,39;23,39,34;26,38,28;28,38,40;27,29,41;27,41,39;30,28,42;42,28,40;29,31,41;41,31,43;31,32,43;43,32,44;32,33,45;32,45,44;33,30,45;45,30,42;34,46,35;35,46,36;36,46,47;36,47,37;37,47,48;37,48,38;39,49,34;34,49,46;46,49,47;47,49,50;47,50,48;48,50,51;40,38,51;51,38,48;41,52,39;39,52,49;49,52,50;50,52,53;53,54,50;50,54,51;42,40,54;54,40,51;41,43,52;43,44,52;52,44,53;44,45,53;53,45,54;45,42,54;];
if (p7(2)==1) %part ID 1=UnitCylinder
res=p7(3); %resolution
scalex=p7(4); %diameter of cylinder in x direction
scaley=p7(5); %diameter of cylinder in y direction
scalez=p7(6); %length of cylinder
rotx=p7(7); %rotation about x axis
roty=p7(8); %rotation about y axis
rotz=p7(9); %rotation about z axis
transx=p7(10); %translation in x direction
transy=p7(11); %translation in y direction
transz=p7(12); %translation in z direction
V7=cylinder.vertices;
V7=[V7(:,1)*scalex, V7(:,2)*scaley, V7(:,3)*scalez];
cylinder.vertices=V7;
a=rotz/57.29; %degrees to radians
V7=cylinder.vertices;
V7=[cos(a)*V7(:,1)-sin(a)*V7(:,2), sin(a)*V7(:,1)+cos(a)*V7(:,2), V7(:,3)];
cylinder.vertices=V7;
a=roty/57.29; %degrees to radians
V7=cylinder.vertices;
V7=[cos(a)*V7(:,1)+sin(a)*V7(:,3), V7(:,2), -sin(a)*V7(:,1)+cos(a)*V7(:,3)];
cylinder.vertices=V7;
a=rotx/57.29; %degrees to radians
V7=cylinder.vertices;
V7=[V7(:,1),cos(a)*V7(:,2)-sin(a)*V7(:,3),sin(a)*V7(:,2)+cos(a)*V7(:,3)];
cylinder.vertices=V7;
V7=cylinder.vertices;
V7=[V7(:,1)+transx, V7(:,2)+transy, V7(:,3)+transz];
cylinder.vertices=V7;
part7=cylinder;
elseif (p7(2)==2) %part ID 2=UnitSphere
res=p7(3); %resolution
scalex=p7(4); %diameter of sphere in x direction
scaley=p7(5); %diameter of sphere in y direction
scalez=p7(6); %diameter of sphere in z direction
rotx=p7(7); %rotation about x axis
roty=p7(8); %rotation about y axis
rotz=p7(9); %rotation about z axis
transx=p7(10); %translation in x direction
transy=p7(11); %translation in y direction
transz=p7(12); %translation in z direction
M7=sphere.vertices;
M7=[M7(:,1)*scalex, M7(:,2)*scaley, M7(:,3)*scalez];
sphere.vertices=M7;
a=rotz/57.29; %degrees to radians
M7=sphere.vertices;
M7=[cos(a)*M7(:,1)-sin(a)*M7(:,2),sin(a)*M7(:,1)+cos(a)*M7(:,2), M7(:,3)];
sphere.vertices=M7;
a=roty/57.29; %degrees to radians
M7=sphere.vertices;
M7=[cos(a)*M7(:,1)+sin(a)*M7(:,3), M7(:,2), -sin(a)*M7(:,1)+cos(a)*M7(:,3)];
sphere.vertices=M7;
a=rotx/57.29; %degrees to radians
M7=sphere.vertices;
M7=[M7(:,1), cos(a)*M7(:,2)-sin(a)*M7(:,3), sin(a)*M7(:,2)+cos(a)*M7(:,3)];
sphere.vertices=M7;
M7=sphere.vertices;
M7=[M7(:,1)+transx, M7(:,2)+transy, M7(:,3)+transz];
sphere.vertices=M7;
part7=sphere;
elseif (p7(2)==3) %part ID 3=UnitCube
res=p7(3); %resolution
scalex=p7(4); %length in x direction
scaley=p7(5); %length in y direction
scalez=p7(6); %length in z direction
rotx=p7(7); %rotation about x axis
roty=p7(8); %rotation about y axis
rotz=p7(9); %rotation about z axis
transx=p7(10); %translation in x direction
transy=p7(11); %translation in y direction
transz=p7(12); %translation in z direction
F7=cube.vertices;
F7=[F7(:,1)*scalex, F7(:,2)*scaley, F7(:,3)*scalez];
cube.vertices=F7;
a=rotz/57.29; %degrees to radians
F7=cube.vertices;
F7=[cos(a)*F7(:,1)-sin(a)*F7(:,2), sin(a)*F7(:,1)+cos(a)*F7(:,2),F7(:,3)];
cube.vertices=F7;
a=roty/57.29; %degrees to radians
F7=cube.vertices;
F7=[cos(a)*F7(:,1)+sin(a)*F7(:,3),F7(:,2), -sin(a)*F7(:,1)+cos(a)*F7(:,3)];
cube.vertices=F7;
a=rotx/57.29; %degrees to radians
F7=cube.vertices;
F7=[F7(:,1), cos(a)*F7(:,2)-sin(a)*F7(:,3),sin(a)*F7(:,2)+cos(a)*F7(:,3)];
cube.vertices=F7;
F7=cube.vertices;
F7=[F7(:,1)+transx, F7(:,2)+transy, F7(:,3)+transz];
cube.vertices=F7;
part7=cube;
else
p7(2)=0;
end
if (p7(2)>0)
Out=[part1,part2,part3,part4,part5,part6,part7];
count=renderpatch(part1)+renderpatch(part2)+renderpatch(part3)+renderpatch(part4)+renderpatch(part5)+renderpatch(part6)+renderpatch(part7);
elseif (p6(2)>0)
Out=[part1,part2,part3,part4,part5,part6];
count=renderpatch(part1)+renderpatch(part2)+renderpatch(part3)+renderpatch(part4)+renderpatch(part5)+renderpatch(part6);
elseif (p5(2)>0)
Out=[part1,part2,part3,part4,part5];
count=renderpatch(part1)+renderpatch(part2)+renderpatch(part3)+renderpatch(part4)+renderpatch(part5);
elseif (p4(2)>0)
Out=[part1,part2,part3,part4];
count=renderpatch(part1)+renderpatch(part2)+renderpatch(part3)+renderpatch(part4);
elseif (p3(2)>0)
Out=[part1,part2,part3];
count=renderpatch(part1)+renderpatch(part2)+renderpatch(part3);
elseif (p2(2)>0)
Out=[part1,part2];
count=renderpatch(part1)+renderpatch(part2);
else
Out=part1;
count=renderpatch(part1);
end
axis off;
grid on
daspect([1 1 1])
light('position',[10,-10,10])
rotate3d on
|