【源码】三维几何工具箱geom3d

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/

更多精彩文章请关注微信号:在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值