资源简介
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 的心音信号处理
相关资源
- malab 的心音信号处理
- 用matlab实现细胞计数
- matlab的mmap
- Harris角点检测拼接包含ransac灰度图像
- 计算并绘制频散曲线的matlab程序
- HDB3码的matlab实现
- 基于Matlab的数据处理与三维模拟
- Matlab 估计资本资产定价模型
- 指纹识别算法MATLAB版本
- 关于PID控制的matlab m语言的仿真程序
- SPWM交流调速的MATLAB仿真
- BP神经网络预测的MATLAB实现
- matlab 信号特征提取
- LDPC 的编译码MATLAB仿真
- MATLAB应用BP神经网络对英文字母的识别
- matlab模式识别感知器实现线性可分、
- TSP商旅问题MATLAB算法
- 节点优化编号
- 增量式PID 的 matlab实现
- 共轭梯度法matlab程序
- 基于Matlab解决TSP问题的蚁群算法
- matlab中doolittle分解、改善的平方根法
- 基于 Matlab 配电网建模仿真的研究
- 6R机械臂正逆解程序
- 计算点到曲线距离的Matlab代码
- Frost滤波MATLAB程序
- matlab遗传算法一
- 基于matlab的动画仿真
- 小波图像压缩matlab源码
- matlab源程序,计算mie散射
评论
共有 条评论