答案 0 :(得分: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
来获取表面而不是线框
答案 1 :(得分:0)
% Draws tetrahedron inscribed in sphere of radius 1
function draw_regular_tetrahedron(T)
T = 1/hypot(1, sqrt(2)/2)*T; % scale to fit in unit sphere
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)