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

📄 object_transform.m

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

basis = [
   [1 0];
   [0 0];
   [0 1];
]';

square = [
  [ 1  1]
  [-1  1];
  [-1 -1];
  [ 1 -1];
  [ 1  1];
]';

% differential scale
S = [ 1.2  0;
        0  0.8];
% rotation
theta = pi/4;
R = [cos(theta) sin(theta);
       -sin(theta) cos(theta)];
% shear
Q = [ 1 1.2;
         0 1];
       
% The active interpretation
figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = S*square;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = R*square;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = Q*square;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
M = (Q*R*S);
obj = M*square;
plot( obj(1,:), obj(2,:), 'r');


% The passive interpretation
figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = S^(-1)*basis;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = R^(-1)*basis;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
obj = Q^(-1)*basis;
plot( obj(1,:), obj(2,:), 'r');

figure;
hold on;
axis equal;
plot( sqrt(3), sqrt(3), 'w.' );
plot( -sqrt(3), -sqrt(3), 'w.' );
plot( basis(1,:), basis(2,:), 'k');
plot( square(1,:), square(2,:), 'b');
M = (Q*R*S);
obj = M^(-1)*basis;
plot( obj(1,:), obj(2,:), 'r');


⌨️ 快捷键说明

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