资源简介
Matlab画圆柱程序,已知三维空间中的两点(圆柱中轴的点),可以绘制圆柱的函数,转载的别人的。
代码片段和文件信息
function [Cylinder EndPlate1 EndPlate2] = cylinder3(X1X2rncyl_colorclosedlines)
%
% This function constructs a cylinder connecting two center points
%
% Usage :
% [Cylinder EndPlate1 EndPlate2] = cylinder3(X1+20X2rn‘r‘closedlines)
%
% Cylinder-------Handle of the cylinder
% EndPlate1------Handle of the Starting End plate
% EndPlate2------Handle of the Ending End plate
% X1 and X2 are the 3x1 vectors of the two points
% r is the radius of the cylinder
% n is the no. of elements on the cylinder circumference (more--> refined)
% cyl_color is the color definition like ‘r‘‘b‘[0.52 0.52 0.52]
% closed=1 for closed cylinder or 0 for hollow open cylinder
% lines=1 for displaying the line segments on the cylinder 0 for only
% surface
%
% Typical Inputs
% X1=[10 10 10];
% X2=[35 20 40];
% r=1;
% n=20;
% cyl_color=‘b‘;
% closed=1;
%
% NOTE: There is a MATLAB function “cylinder“ to revolve a curve about an
% axis. This “Cylinder“ provides more customization like direction and etc
% Calculating the length of the cylinder
length_cyl=norm(X2-X1);
% Creating a circle in the YZ plane
t=linspace(02*pin)‘;
x2=r*cos(t);
x3=r*sin(t);
% Creating the points in the X-Direction
x1=[0 length_cyl];
% Creating (Extruding) the cylinder points in the X-Directions
xx1=repmat(x1length(x2)1);
xx2=repmat(x212);
xx3=repmat(x312);
% Drawing two filled cirlces to close the cylinder
if closed==1
hold on
EndPlate1=fill3(xx1(:1)xx2(:1)xx3(:1)‘r‘);
EndPlate2=fill3(xx1(:2)xx2(:2)xx3(:2)‘r‘);
end
% Plotting the cylinder along the X-Direction with required length starting
% from Origin
Cylinder=mesh(xx1xx2xx3);
% Defining Unit vector along the X-di
相关资源
- matlab程序 理想低通滤波器
- matlab作smith chart
- 用matlab产生3维的高斯分布
- HookeJeeves优化程序
- verhulst的matlab程序
- 通过matlab建立Kd-tree并进行k-NN查询
- BP算法MATLAB程序
- 基于遗传算法的OFDM自适应资源分配算
- LSA算法MATLAB测试代码
- matlab调用ansys运算源码与文档
- 马赛克matlab
- 模拟高斯激光传播
- Doubly modifide Hausdorff distance-MATLAB
- 显色指数的MATLAB计算程序
- 区域生长图像分割-MATLAB程序,注释比
- FasterRcnn2.m
- 计算两幅图像的psnr值matlab
- NSGA-II_matlab库
- 涡格法计算气动力MATLAB
- 无刷直流电机MATLAB仿真模型
- matlab实现灰度图的jpeg编码过程
- bfgs算法-matlab源程序
- 边界元法的MATLAB程序
- 解决灾情巡视TSP问题数模的MATLAB程序
- NLMS程序代码_matlab
- OFDM通信系统的Matlab仿真 源程序 m文件
- PCM_FSK_ASK_DPSK仿真源码(matlab实现)
- 移动最小二乘法计算程序
- 泽尼克多项式表达式计算
- matlab下进行的凸轮轮廓线的设计
评论
共有 条评论