⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 object_anim.m

📁 用MATLAB做的3D图形的变化,这个是范例,希望会帮到大家
💻 M
字号:
close all;
clear all;

% a corner at the origin
corner= [
   [1 0];
   [0 0];
   [0 1];
]';

% define an object
object = [
  [ 1  0];
  [ 0  1];
  [ 0.5  0];
  [ 0 -1];
  [ 1  0];
]';

% rotation
theta = 10*pi/180;
R = [
  cos(theta) -sin(theta);
  sin(theta) cos(theta)
];

N = round(2*pi/theta); % N = number of animation frames

w = 1.25;
M = moviein(N);
for i = 1:N
  % make a movie frame
  figure;
  h = axes;
  hold on;
  % draw a picture
  plot( w,w, 'w' );
  plot( -w,-w, 'w' );
  plot( corner(1,:), corner(2,:), 'k' );
  plot( object(1,:),object(2,:));
  % save the frame
  M(i,:) = getframe;
  % close the frame
  close;
  % move the object for the next movie frame
  object = R*object;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -