Home > bioelectromagnetism > Polyhedra.m

Polyhedra

PURPOSE ^

one of five regular polyhedra

SYNOPSIS ^

function polyhedron=Polyhedra(ptype);

DESCRIPTION ^

one of five regular polyhedra
in a format consistent with hieracrhical 
modeler scaled to fit inside a unit sphere

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function polyhedron=Polyhedra(ptype);
0002 
0003 %one of five regular polyhedra
0004 %in a format consistent with hieracrhical
0005 %modeler scaled to fit inside a unit sphere
0006 
0007 if (strcmp(ptype,'tetrahedron'))
0008    polyhedron.vertices=[...
0009          0.453608  0.890430  0.037037
0010       0.544331 -0.628540 -0.555555
0011       -0.090722 -0.366647  0.925925
0012       -0.907218  0.104757 -0.407407
0013    ];
0014    
0015    polyhedron.faces=1+[...
0016          0 1 2
0017       0 1 3
0018       0 2 3
0019       1 2 3
0020    ];
0021    
0022 elseif (strcmp(ptype,'cube'))
0023    polyhedron.vertices=0.5774*[...
0024          0 0 0; 1 0 0; 1 1 0; 0 1 0; ...
0025          0 0 1; 1 0 1; 1 1 1; 0 1 1;] ;
0026    
0027    polyhedron.vertices=polyhedron.vertices *2 - 0.5774;
0028    
0029    polyhedron.faces=[ 1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; ...
0030          1 2 3 4; 5 6 7 8; ] ;
0031    
0032 elseif (strcmp(ptype,'octahedron'))
0033    polyhedron.vertices=[...
0034          0.408248  0.707107 -0.577350
0035       0.408248 -0.707107 -0.577350
0036       0.816496  0.000000  0.577350
0037       -0.408248  0.707107  0.577350
0038       -0.408248 -0.707107  0.577350
0039       -0.816496  0.000000 -0.577350
0040    ];
0041    polyhedron.faces=1+[...
0042          3 2 0
0043       3 0 5
0044       5 0 1
0045       0 2 1
0046       3 5 4
0047       5 1 4
0048       4 1 2
0049       4 2 3
0050    ];
0051    
0052 elseif (strcmp(ptype,'dodecahedron'))
0053    polyhedron.vertices=[...
0054          0.175988  0.745447 -0.642912
0055       0.230032  0.972675  0.031428
0056       0.276500 -0.379561 -0.882882
0057       0.392664 -0.847627 -0.356851
0058       0.417990  0.215329  0.882563
0059       0.480109 -0.479965  0.734253
0060       0.643598  0.214231 -0.734769
0061       0.731044  0.581893  0.356335
0062       0.831555 -0.543116  0.116366
0063       0.986641  0.113149 -0.117200
0064       -0.175988 -0.745447  0.642912
0065       -0.230033 -0.972675 -0.031428
0066       -0.276499  0.379562  0.882882
0067       -0.392664  0.847627  0.356851
0068       -0.417989 -0.215329 -0.882563
0069       -0.480109  0.479965 -0.734254
0070       -0.643598 -0.214231  0.734769
0071       -0.731044 -0.581893 -0.356336
0072       -0.831555  0.543115 -0.116366
0073       -0.986641 -0.113149  0.117200
0074    ];
0075    polyhedron.faces=1+[...
0076          17 19 18 
0077       18 15 14 
0078       17 18 14 
0079       1 0 15 
0080       15 18 13 
0081       1 15 13 
0082       6 2 14 
0083       14 15 0 
0084       6 14 0 
0085       3 11 17 
0086       17 14 2 
0087       3 17 2 
0088       10 16 19 
0089       19 17 11 
0090       10 19 11 
0091       12 13 18 
0092       18 19 16 
0093       12 18 16 
0094       16 10 5 
0095       5 4 12 
0096       16 5 12 
0097       11 3 8 
0098       8 5 10 
0099       11 8 10 
0100       2 6 9 
0101       9 8 3 
0102       2 9 3 
0103       0 1 7 
0104       7 9 6 
0105       0 7 6 
0106       13 12 4 
0107       4 7 1 
0108       13 4 1 
0109       7 4 5 
0110       5 8 9 
0111       7 5 9 
0112    ];
0113    
0114 elseif (strcmp(ptype,'icosahedron'))
0115    polyhedron.vertices=[...
0116          0.250254 -0.916162 -0.313083
0117       0.320072 -0.078054 -0.944171
0118       0.437594 -0.598061  0.671442
0119       0.550563  0.758025 -0.349682
0120       0.623196  0.436642  0.648821
0121       0.975676 -0.177816 -0.128204
0122       -0.250253  0.916161  0.313082
0123       -0.320073  0.078054  0.944172
0124       -0.437593  0.598061 -0.671442
0125       -0.550563 -0.758024  0.349683
0126       -0.623195 -0.436643 -0.648822
0127       -0.975676  0.177817  0.128204
0128    ];
0129    polyhedron.faces=1+[...
0130          3 4 5
0131       4 7 2
0132       3 5 1
0133       5 2 0
0134       3 1 8
0135       1 0 10
0136       3 8 6
0137       8 10 11
0138       3 6 4
0139       6 11 7
0140       2 5 4
0141       9 2 7
0142       0 1 5
0143       9 0 2
0144       10 8 1
0145       9 10 0
0146       11 6 8
0147       9 11 10
0148       7 4 6
0149       9 7 11
0150    ];
0151    
0152 else
0153    error('type must be:tetrahedron, cube, octahedron,dodecahedron,icosahedron');
0154    
0155 end

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003