下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 麻纺企业员工考勤管理规定
- 包装材料研发工程师岗位招聘考试试卷及答案
- 第14讲 牛顿运动定律的应用1
- 4.4 光的折射 课件(共24张) 2025-2026学年人教版初中物理八年级上册
- 护理技术创新在团队服务中的提升
- 子宫动脉超声评估:临床意义、操作方法与参数解读(完整版临床指南)
- 安徽省黄山市重点中学2026届高三第九次调研考试化学试题试卷含解析
- 福建省宁德一中等重点中学2026年高三下学期第六次质量调研考试化学试题含解析
- 14.1《法治与改革相互促进》教案 2025-2026学年统编版道德与法治八年级下册
- 细胞互作在再生中的作用
- 2025年高考数学全国一卷试题真题及答案详解(精校打印)
- T/CCMA 0168-2023土方机械电控手柄技术要求及试验方法
- 成人癌性疼痛护理团体标准
- 2025年统计学期末考试题库:时间序列分析核心考点解析
- 实验室生物安全应急预案
- DG-TJ08-2177-2023建筑工程消防施工质量验收标准
- 《低聚糖功能性质》课件
- 华南理工大学《工程热力学》2023-2024学年第一学期期末试卷
- T-NBHTA 004-2024 热处理企业环境保护技术规范
- DB32T 4786-2024 城镇供水服务质量标准
- 9.1美国基础知识讲解七年级地理下学期人教版
评论
0/150
提交评论