📄 object_transform.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 + -