2012-07-06 633 views
4

我想在MATLAB中繪製四面體。我怎樣才能做到這一點?在MATLAB中繪製四面體R2011a

a busy cat

+0

你至少知道它的頂點座標嗎? – mathematician1975 2012-07-06 08:41:21

+0

我谷歌,我發現在mathworks.com在MATLAB R2012a存在這樣做的方法。但在MATLAB R2011a中沒有這樣的方法。 – user559096 2012-07-06 08:43:32

+0

你可以做到這一點 - 你可能需要努力一點。你有頂點的座標嗎? – mathematician1975 2012-07-06 08:45:09

回答

3

試試這個

X = [x1 x2 x3 x4]'; 
Y = [y1 y2 y3 y4]'; 
Z = [z1 z2 z3 z4]';  
T = [1 2 3; 1 2 4; 2 3 4; 1 3 4];  
trimesh(T,X,Y,Z); 

,看看它是否工作。值x1 y1和z1分別是頂點1的x y x座標(類似於其他頂點)。我現在沒有MATLAB訪問權限,所以我從八角形生成器代碼修改了這個。您可能需要與頂點爲了得到它的工作打,但這種方法將使你能夠畫出你的四面體

編輯:另一種選擇是trisurf代替trimesh拿到表面,而不是線框

0
% Draws tetrahedron inscribed in sphere of radius 1 
    function draw_regular_tetrahedron(T) 
     z = 1/sqrt(2); 
     S.Vertices = (T*[1,0,-z;-1,0,-z;0,1,z;0,-1,z]')'; 
     S.Faces = [1,3,4;2,3,4;1,2,3;1,2,4]; 
     S.FaceVertexCData = [ 1 ]; 
     S.FaceColor = 'flat'; 
     S.EdgeColor = 'green'; 
     p = patch(S); 
     alpha(p, 0.5); 
    end 

>> ps_5_2.draw_regular_tetrahedron(eye(3)) 
>> ps_5_2.draw_regular_tetrahedron(eye(3)*5) 

enter image description here