下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、用Matlab畫圓柱圓臺圓錐自己建一個M文件,命名任意,如tu.m在命令窗口輸入:tu%以下為tu.m文件clcclear all%圓柱X,Y,Z=cylinder(15.7,20);h=1.22*Z;surf(X,Y,h);hold on%圓臺a=25/180*pi;%可修改b=12.06/180*pi;%可修改r=3.2;%可修改h1=r*sin(a+b)/sin(a-b)*sin(a);%h1=0.66;X1=0 0 1.22;%底面中心坐標(biāo)X2=0 0 1.22+h1;%頂面中心坐標(biāo)L2=15.7-2.6/tan(a);r=15.7 L2;n=20;cyl_color=b;closed
2、=1;lines=1;cone,EndPlate1,EndPlate2 = Cone(X1,X2,r,n,cyl_color,closed,lines)%調(diào)用圓臺的函數(shù)%圓錐X2,Y2,Z2=cylinder(L2:-0.2:0);h2=1.5;%可修改Z2=h2*Z2;Z2=Z2+ones(size(Z2)*(1.22+h1);surf(X2,Y2,Z2);grid on%r=0:0.1:3.2;R=0:0.1:15.7;%alpha=0:pi/20:2*pi;%角度0,2*pi%x=R*cos(alpha);%y=R*sin(alpha);%a=39.0;b=12.06;%h=1.22+R
3、.*tan(b)+r.*sin(a);%x,y=meshgrid(-4:0.5:4);%surf(h)新建一個M文件,如下命名為Cone.Mfunction Cone,EndPlate1,EndPlate2 = Cone(X1,X2,R,n,cyl_color,closed,lines)% This function constructs a cylinder connecting two center points % % Usage :% Cone,EndPlate1,EndPlate2 = Cone(X1,X2,R,n,cyl_color,closed,lines)% % Cone-Ha
4、ndle of the cone% 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/cone R(1) = start radius, R(2) = end radius% n is the no. of elements on the cylinder circumference (more- refined)
5、% 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 5;% n=20;% cyl_color=b;% closed=1;% % NOTE: There i
6、s a MATLAB function cylinder to revolve a curve about an% axis. This Cylinder provides more customization like direction and etc%圓臺的函數(shù),文件名為Cone.m% Calculating the length of the Conelength_cyl=norm(X2-X1);% Creating 2 circles in the YZ planet=linspace(0,2*pi,n);xa2=R(1)*cos(t);xa3=R(1)*sin(t);xb2=R(2
7、)*cos(t);xb3=R(2)*sin(t);% Creating the points in the X-Directionx1=0 length_cyl;% Creating (Extruding) the cylinder points in the X-Directionsxx1=repmat(x1,length(xa2),1);xx2=xa2 xb2;%xx2=repmat(x2,1,2);xx3=xa3 xb3;%xx3=repmat(x3,1,2);% Drawing two filled cirlces to close the cylinderif closed=1 ho
8、ld 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 OriginCone=mesh(xx1,xx2,xx3);% Defining Unit vector along the X-directionunit_Vx=1 0 0;% Calulating the angle betwee
9、n the x direction and the required direction% of Cone through dot productangle_X1X2=acos( dot( unit_Vx,(X2-X1) )/( norm(unit_Vx)*norm(X2-X1) )*180/pi;% Finding the axis of rotation (single rotation) to roate the Cone in% X-direction to the required arbitrary direction through cross productaxis_rot=c
10、ross(1 0 0,(X2-X1) );% Rotating the plotted Cone and the end plate circles to the required% anglesif angle_X1X2=0 % Rotation is not needed if required direction is along X rotate(Cone,axis_rot,angle_X1X2,0 0 0) if closed=1 rotate(EndPlate1,axis_rot,angle_X1X2,0 0 0) rotate(EndPlate2,axis_rot,angle_X
11、1X2,0 0 0) endend% Till now Cone has only been aligned with the required direction, but% position starts from the origin. so it will now be shifted to the right% positionif closed=1 set(EndPlate1,XData,get(EndPlate1,XData)+X1(1) set(EndPlate1,YData,get(EndPlate1,YData)+X1(2) set(EndPlate1,ZData,get(
12、EndPlate1,ZData)+X1(3) set(EndPlate2,XData,get(EndPlate2,XData)+X1(1) set(EndPlate2,YData,get(EndPlate2,YData)+X1(2) set(EndPlate2,ZData,get(EndPlate2,ZData)+X1(3)endset(Cone,XData,get(Cone,XData)+X1(1)set(Cone,YData,get(Cone,YData)+X1(2)set(Cone,ZData,get(Cone,ZData)+X1(3)% Setting the color to the
13、 Cone and the end platesset(Cone,AmbientStrength,1,FaceColor,cyl_color,FaceLighting,gouraud);%,EdgeColor,none)if closed=1 set(EndPlate1 EndPlate2,AmbientStrength,1,FaceColor,cyl_color,FaceLighting,gouraud);%,EdgeColor,none)else EndPlate1=; EndPlate2=;end% If lines are not needed making it disapearif lines=0 set(Cone,EdgeAlpha,0)end%shading faceted % faceted flat interp;%camlight; %light;%lighting gouraud; %flat g
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版承包工地食堂餐廚垃圾處理合同模板3篇
- 2024蔬菜加工產(chǎn)品銷售合作協(xié)議3篇
- 2024年股權(quán)轉(zhuǎn)讓合同標(biāo)的及屬性詳細(xì)描述
- 2024年版物業(yè)托管服務(wù)協(xié)議版B版
- 二零二五版離婚協(xié)議書起草與審核合同2篇
- 2024版房屋贈與合同協(xié)議書大全
- 天津中德應(yīng)用技術(shù)大學(xué)《教育技術(shù)與傳播》2023-2024學(xué)年第一學(xué)期期末試卷
- 二零二五版家政服務(wù)+家庭健康促進(jìn)合同3篇
- 太原幼兒師范高等專科學(xué)?!段麽t(yī)外科學(xué)醫(yī)學(xué)免疫學(xué)與病原生物學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 二零二五年特殊用途變壓器安裝與性能測試合同2篇
- 《浸沒式液冷冷卻液選型要求》
- 迪士尼樂園總體規(guī)劃
- 2024年江蘇省蘇州市中考數(shù)學(xué)試卷含答案
- 2024年世界職業(yè)院校技能大賽高職組“市政管線(道)數(shù)字化施工組”賽項考試題庫
- 介紹蝴蝶蘭課件
- 大學(xué)計算機基礎(chǔ)(第2版) 課件 第1章 計算機概述
- 數(shù)字化年終述職報告
- 2024年職工普法教育宣講培訓(xùn)課件
- 安保服務(wù)評分標(biāo)準(zhǔn)
- T-SDLPA 0001-2024 研究型病房建設(shè)和配置標(biāo)準(zhǔn)
- (人教PEP2024版)英語一年級上冊Unit 1 教學(xué)課件(新教材)
評論
0/150
提交評論