当前位置:网站首页>旋转的扇形---MATLAB(动画演示)
旋转的扇形---MATLAB(动画演示)
2022-04-22 17:09:00 【小宇2022】

function sector2
%调用:直接在命令行输入sector2
%用途:采用定时器创建旋转的转盘
%设置圆形的圆心和半径、扇形的弧角
r0 = [3,3];%圆心
radius = 2;
radian = 2*pi/3;
%创建窗口
hFig = figure('Name', '旋转的扇形',...
'visible', 'off',...
'UserData', 0);
%创建坐标轴
hAxes = axes('parent', hFig,...
'DrawMode', 'fast',...
'box', 'on',...
'xticklabel', '',...
'yticklabel', '',...
'XTick', [],...
'YTick', []);
%坐标轴等比例
axis equal;
%创建3个扇形
hp1 = patch('faceColor', 'r', 'parent', hAxes);
hp2 = patch('faceColor', 'y', 'parent', hAxes);
hp3 = patch('faceColor', 'b', 'parent', hAxes);
%显示窗口
set(hFig, 'visible', 'on');
%创建定时器并启动
t = timer('BusyMode', 'queue', 'ExecutionMode', 'fixedSpacing', ...
'Period', 0.05, 'TimerFcn', {
@update, hFig, hp1, hp2, hp3,radian,r0,radius});
start(t); %启动定时器
%% 定时器回调函数
function update(obj, ~, hFig, hp1, hp2, hp3,radian,r0,radius)
%若没有关闭窗口,刷新随机数值
if ishandle(hFig)
%重新获取弧度值
rad0 = get(hFig, 'UserData');
t0 = (rad0:0.1:rad0+radian+0.1);
t1 = t0+2*pi/3;
t2 = t1+2*pi/3;
%获取扇形弧边数据
x0 = r0(1)+radius*cos(t0);
y0 = r0(2)+radius*sin(t0);
x1 = r0(1)+radius*cos(t1);
y1 = r0(2)+radius*sin(t1);
x2 = r0(1)+radius*cos(t2);
y2 = r0(2)+radius*sin(t2);
%绘制扇形patch对象
set(hp1,'xdata',[r0(1),x0],'ydata',[r0(2),y0]);
set(hp2,'xdata',[r0(1),x1],'ydata',[r0(2),y1]);
set(hp3,'xdata',[r0(1),x2],'ydata',[r0(2),y2]);
%扇形顺时针转0.1弧度
set(hFig, 'UserData', rad0+0.1);
drawnow;
else %若关闭窗口
stop(obj); %停止定时器
delete(obj); %删除定时器
end
版权声明
本文为[小宇2022]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_38127487/article/details/124336887
边栏推荐
- Devaxpress WPF Getting Started Guide - POCO view model generated at runtime (I)
- Which financial product has high income on May Day?
- leetcode:451. 根据字符出现频率排序
- SDN学习之Opendaylight浅析(二)
- The recursive return value in JS is undefined
- 2022 EIA Engineer Examination case analysis exercises and answers
- Sequoia China led the team and voted for two female founders
- GlobalMapper20 如何批量把dwg文件转换为dxf文件,效率神器
- Check whether the paper is retrieved by SCI
- How to select ECS
猜你喜欢

知乎香港上市,首家以双重主要上市回港的中概股

从0开始设计_基于STM32F1的RC522读写卡

今天又出bug了,在用到mogoDb查询数据时,发现返回的数据为null...

Design from 0_ Rc522 read / write card based on stm32f1

2022年环境影响评价工程师考试相关法律法规练习题及答案

GlobalMapper20 如何批量把dwg文件转换为dxf文件,效率神器

Shiro缓存管理

SaaS 长河下,AfterShip 技术升级的“加减法”

刘畊宏是抖音的钻头
![[distributed project] certification service center, social login oauth2 0. Single sign on and distributed session solutions](/img/b5/c4fb21101a8d4b83de760d0feda296.png)
[distributed project] certification service center, social login oauth2 0. Single sign on and distributed session solutions
随机推荐
Design from 0_ Rc522 read / write card based on stm32f1
深度学习笔记(一)——损失函数
Will Liu is a tiktok bit.
CLion 中添加 release 配置
Leetcode problem brushing plan -- monotonic sequence
[句型] 二十四、特殊疑问句
LeetCode刷题计划——单调数列
Sequoia China led the team and voted for two female founders
Apache配置多端口
How can we make the calendar note of win10 computer display 24 solar terms?
ASP. Net core to realize JWT authorization and authentication (2. Practical part)
E-commerce price data monitoring interface / brand commodity price control interface / commodity data analysis interface / price comparison search API interface, ultra detailed interface docking instr
测试人生 | 毕业2年未满,0经验拿下知名互联网企业30W 年薪,他是怎么做到的?
OJ daily practice -- find the sum of score sequences
2022年环境影响评价工程师考试案例分析练习题及答案
webrtc入门:4.RTCPeerConnection连接音视频流
从0开始设计_基于STM32F1的RC522读写卡
Shiro cache management
[unity] make aim IK 1 with animation rig
蕉下在走完美日记的老路