


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、function demoDisplayclearclcclose all;x,y,z = heart;bottomZ = min(z(:);radius = abs(bottomZ);axis vis3daxis offdaspect(1.6, 1, 1.875);hold on;markerColor = 0.5, 0.5, 0.5;lineColor = 0.7, 0.7, 0.7;figWidth = 800figHeight = 600;screenSize = get(0, ScreenSize);X0 = (screenSize(3)-figWidth)/2;Y0 = (scre
2、enSize(4)-figHeight)/2;set(gcf, Position, X0,Y0, figWidth, figHeight);camtarget(0, 0, 0);set(gcf,Renderer,zbuffer);set(gcf,DoubleBuffer,on);% RGB(255 105 180) is for pink colorset(gcf, color, 255 255 255/255);startAZ = 30;satrtEL = 20;view(startAZ, satrtEL);% draw pointsfor iLoop = 1:size(x, 1)plot3
3、(x(iLoop, :), y(iLoop,:), z(iLoop, :), Marker, ., MarkerEdgeColor, markerColor, LineStyle, none);pause(0.2);end% draw wire framesfor iLoop = 1:size(x, 1)plot3(x(iLoop, :), y(iLoop,:), z(iLoop, :), color, lineColor, LineStyle, -);pause(0.1);endfor iLoop = 1:size(x, 2)plot3(x(:, iLoop), y(:, iLoop), z
4、(:, iLoop), color, lineColor, LineStyle, -);pause(0.1);end% rotate wire framefor i=1:36camorbit(10,0,data);pause(0.1);end% clean the curent axesdelete(get(gca, Children);camlight left;newLineColor = 0.7, 0.4, 0.4;% re-draw the whole heart with surf functionh = surf(x,y,z, EdgeColor, newLineColor, Fa
5、ceColor, r);for i=1:36camorbit(10,0,data);pause(0.1);endmediumColor = 0.8, 0.3, 0.3;set(h, EdgeColor, mediumColor,FaceLighting,gouraud);for i=1:36camorbit(10,0,data);drawnow;endset(h, EdgeColor, none);drawnow;% define the Z-path for heart re-shapedeltaZ = linspace(-.3, 0, 5);deltaZ = fliplr(deltaZ),
6、 deltaZ;deltaZ = repmat(deltaZ, 1, 3);zlim(manual);for iLoop = 1:length(deltaZ)% draw the bouncing heartcurDeltaZ = deltaZ(mod(iLoop,length(deltaZ)+1);ratio = (radius+curDeltaZ)*radius;newZ = z*ratio + curDeltaZ;if exist(h, var)& ishandle(h), delete(h);end;h = surf(x,y, newZ, EdgeColor, none, FaceCo
7、lor, r,FaceLighting,gouraud);camorbit(-1, 0, data);drawnow;end% draw the bouncing heartdeltaZ = generateSimulatedBouncingPath;zlim(-1, 3);for iLoop = 1:length(deltaZ)if exist(h, var)& ishandle(h), delete(h);end;curDeltaZ = deltaZ(iLoop);if curDeltaZ 0% when deltaZ is under the zero bar, its hitting
8、the groundratio = (radius+curDeltaZ)*radius;newZ = z*ratio + curDeltaZ;else% when deltaZ is bigger than zero, its a free objectnewZ = z + curDeltaZ;endh = surf(x, y, newZ, EdgeColor, none, FaceColor, r,FaceLighting,gouraud);% zoom in and out for more vivid effectif iLoop = length(deltaZ)/2camzoom(0.
9、99);elsecamzoom(1.005);endcamorbit(390/length(deltaZ), 0, data);drawnow;endtext(0.3,2.4, X,FontSize,25,FontName,Times New Roman)%text(0.3,1.8, X,FontSize,30,FontName,Times New Roman)%endfunction z = generateSimulatedBouncingPath(iterationNum, roundTimes)% define the z path of the center of ball for
10、rountTimes of bouncing along z-axisif nargin 2roundTimes = 3;endif nargin 1iterationNum = 40;endradius = 1;deltaH = 1.5; % the highest point comapred with radiusdeltaL = -0.3;% the lowest point comapred with radiusrangeY = -2, 1;% gravity accelerator constant% Note: this is smaller to the real 9.8 v
11、alue, but this makes the bouncing slowerg = 5;% define the accelerator for the z 0plusZtime = sqrt(2*deltaH*radius/g);% time for z 0zPlus = startZ - 0.5 * g * qPeriodTime(qPeriodTimeplusZtime).2;% z path when z =plusZtime)-plusZtime) + 0.5 * k* (qPeriodTime(qPeriodTime =plusZtime)-plusZtime).2;z = z
12、Plus, zMinus, fliplr(zMinus), fliplr(zPlus);% the last zPlus is for the stop actionz = repmat(z, 1, roundTimes), zPlus;y = linspace(rangeY(1), rangeY(2), numel(z);endfunction cordX, cordY, cordZ = heart(sizeTheta, sizeFai)if nargin =0sizeTheta = 30;sizeFai = 40;elseif nargin 2error(heart:NotEnoughAr
13、ugments, Please give at least two input arugments);end;theta = linspace(0, pi, sizeTheta);nudge = 0.0001; % used to avoid the operlappingfai = linspace(0 + nudge, pi/2 - nudge, round(sizeFai/4);a = 9/4;b = 9/80;A = 1+(a-1)*(sin(theta).2) * (sin(fai).2);B = (sin(theta).2.*cos(theta).3) * (1 + (b-1)*(
14、sin(fai).2);rou = zeros(size(A);for iLoop = 1:numel(A);curA = A(iLoop);curB = B(iLoop);% this is the polar coordinates version of the sextic equation found on% /HeartSurface.htmlpolyFactors = curA3, -curB, -3*curA2, 0, 3*curA, 0, -1;solutions = roots(polyFactors);realRou = real(solutions(abs(imag(solutions)0);end% x,y,z for the quater of whole heartx = rou .* (sin(theta)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 土建科技課題申報(bào)書
- 2025年中國微型收割機(jī)市場調(diào)查研究報(bào)告
- 注冊(cè)會(huì)計(jì)師團(tuán)隊(duì)作業(yè)實(shí)務(wù)試題及答案
- 2025年財(cái)務(wù)行業(yè)的創(chuàng)新與實(shí)踐探索試題及答案
- 內(nèi)蒙古自治區(qū)烏蘭察布市集寧區(qū)一中2025屆高三第三次測評(píng)語文試卷含解析
- 汽車修理工個(gè)人年終工作總結(jié)(28篇)
- 注冊(cè)會(huì)計(jì)師備考的有效策略與應(yīng)試技巧分析試題及答案
- 財(cái)務(wù)管理新視角試題及答案2025
- 項(xiàng)目管理知識(shí)應(yīng)用及答案
- 深入分析2025年證券從業(yè)資格證考試的歷史及現(xiàn)狀試題及答案
- GB/T 14713-2009旋切機(jī)通用技術(shù)條件
- 低成本自動(dòng)化的開展與案例課件
- 不予受理反訴民事上訴狀(標(biāo)準(zhǔn)版)
- 高中英語語法之虛擬語氣(課件3份)
- 粵教版2022年小學(xué)六年級(jí)科學(xué)下冊(cè)期中測試試卷及答案2022-2023
- 北師大六年級(jí)下冊(cè)數(shù)學(xué)第三單元《圖形的運(yùn)動(dòng)》教學(xué)設(shè)計(jì)
- 國際石油合作主要合同模式課件
- 橋梁加固改造工程施工質(zhì)量管理體系與措施
- 第二十六章慢性腎小球腎炎演示文稿
- 設(shè)施設(shè)備維修記錄表
- 自動(dòng)化設(shè)備檢修規(guī)程
評(píng)論
0/150
提交評(píng)論