资源简介
Matlab与CAD软件直接的图形相互输入接口
里面有初步的成型的算法!

代码片段和文件信息
function cad2matdemo(filename)
% CAD2MATDEMO a demonstration of importing 3D CAD data into Matlab.
% To get CAD data into Matlab the process is:
%
% 1) Export the 3D CAD data as an ASCII STL (or Pro/E render SLP) file.
% 2) This Matlab routine reads the CAD data
% 3) Once read the CAD data is rotated around a bit.
%
% Program has been tested with: AutoCAD Cadkey and Pro/Engineer.
% Should work with most any CAD programs that can export STL.
%
% Format Details: STL is supported and the color version of STL
% that Pro/E exports called ‘render.‘ The render (SLP) is just
% like STL but with color added.
%
% Note: This routine has both the import function and some basic
% manipulation for testing. The actual reading mechanism is located
% at the end of this file.
if nargin == 0
filename = ‘hook.stl‘; % a simple demo part
warning([‘No file specified using demo file: ‘ filename]);
end
%
% Read the CAD data file:
[F V C] = rndread(filename);
clf;
p = patch(‘faces‘ F ‘vertices‘ V);
%set(p ‘facec‘ ‘b‘); % Set the face color (force it)
set(p ‘facec‘ ‘flat‘); % Set the face color flat
set(p ‘FaceVertexCData‘ C); % Set the color (from file)
%set(p ‘facealpha‘.4) % Use for transparency
set(p ‘EdgeColor‘‘none‘); % Set the edge color
%set(p ‘EdgeColor‘[1 0 0 ]); % Use to see triangles if needed.
light % add a default light
daspect([1 1 1]) % Setting the aspect ratio
view(3) % Isometric view
xlabel(‘X‘)ylabel(‘Y‘)zlabel(‘Z‘)
title([‘Imported CAD data from ‘ filename])
drawnow % axis manual
%
disp([‘CAD file ‘ filename ‘ data is read will now show object rotating‘])
pause(1)
%
% Move it around.
% To use homogenous transforms the n by 3 Vertices will be turned to
% n by 4 vertices then back to 3 for the set command.
% Note: n by 4 needed for translations not used here but could using tl(xyz)
V = V‘;
V = [V(1:); V(2:); V(3:); ones(1length(V))];
%
vsize = maxv(V); %attempt to determine the maximum xyz vertex.
AXIS([-vsize vsize -vsize vsize -vsize vsize]);
%
for ang = 0:1:90
nv = rx(ang)*V;
set(p‘Vertices‘nv(1:3:)‘)
drawnow
end
for ang1 = 0:2:90
nv1 = ry(ang1)*nv;
set(p‘Vertices‘nv1(1:3:)‘)
drawnow
end
for ang2 = 0:3:90
nv2= rz(ang2)*nv1;
set(p‘Vertices‘nv2(1:3:)‘)
drawnow
end
for ang3 = 0:5:180
nv3 = rx(ang3)*ry(ang3)*rz(ang3)*nv2;
set(p‘Vertices‘nv3(1:3:)‘)
drawnow
end
%
% End of main routine here are the functions used:
% Homogeneous manipulation functions follow:
%
function Rx = rx(THETA)
% ROTATION ABOUT THE X-AXIS
%
% Rx = rx(THETA)
%
% This is the homogeneous transformatio
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4243 2004-03-10 21:19 surf2stl.m
----------- --------- ---------- ----- ----
4243 1
- 上一篇:用matlab实现细胞计数
- 下一篇:malab 的心音信号处理
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论