geom3d库的目的是处理和可视化三维几何基本体,如点、线、平面、多面体…
The aim of geom3d library is to handle and visualize 3D geometric primitives such as points, lines, planes, polyhedra…
提供了操作三维几何基本体的低级功能,使更复杂几何算法的开发更加容易。
It provides low-level functions for manipulating 3D geometric primitives, making easier the development of more complex geometric algorithms.
示例如下:
1)初始化Initialisation
% 提取球型多面体的顶点、边和面extract vertices, edges, and faces of soccerball polyhedron
[vertices edges faces] = createSoccerBall;
% 准备画图prepare figure
figure(1); clf; hold on;
axis equal;
view(3);
% 绘制多面体draw the polyhedron as basis
drawPolyhedron(vertices, faces);
2)绘制为绿色边缘的圆柱体Draw each edge as a green cylinder
figure; hold on;
axis equal;
view(3);
width = .05;
radius = .1;
for i = 1:size(edges, 1)
p1 = vertices(edges(i, 1), :);
p2 = vertices(edges(i, 2), :);
drawCylinder([p1 p2 width], 'FaceColor', 'g');
end
3)将每个顶点绘制为蓝色球体Draw each vertex as a blue ball
for i = 1:size(vertices, 1)
drawSphere([vertices(i, :) radius], 'FaceColor', 'b');
end
4)显示设置
set(gcf, ‘renderer’, ‘opengl’)
light;
view([10 30]);
源码下载地址:
http://page2.dfpan.com/fs/9lcjf221b291f6caa88/
更多精彩文章请关注微信号: