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

📄 object_anim2.m

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

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

% defne an object using homogeous coordinates
object = [
  [ 1  0 1];
  [ 0  1 1];
  [ 0.5  0 1];
  [ 0 -1 1];
  [ 1  0 1];
]';

% rotation in homogeneous coordinates
theta = 10*pi/180;
R = [
  cos(theta) -sin(theta) 0;
  sin(theta) cos(theta) 0;
  0              0              1
];
% translation in homogeneous coordinates      
T = [
  1 0 0.7
  0 1 0
  0 0 1
];

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

figure;
hold on;
axis equal;
h = object_draw( corner );
set( h, 'Color', 'k' );
for i = 0:N
  B = (T*R)^i;
  object_draw( B*object );
  plot( 2,2, 'w.' );
  plot( -2,-2, 'w.' );
end

figure;
hold on;
axis equal;
h = object_draw( corner );
set( h, 'Color', 'k' );
for i = 0:16
  B = (T^i)*(R^i);
  object_draw( B*object );
  plot( 2,2, 'w.' );
  plot( -2,-2, 'w.' );
end

⌨️ 快捷键说明

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