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

📄 transfor.m

📁 ransfor函数是一个可以用来做线性变换图形显示的函数.
💻 M
字号:
function transfor       
%       ATLAST Transformer utility. 
%
% This utility allows one to see graphically the
% effects of linear transformations on geometric
% figures. 
%
% An initial image is selected from a pull-down
% image menu. One can then select a transformation,
% either Rotation, Reflection, or Diagonal. The user
% must input either the degrees of rotation or reflection
% or the scaling factors of the diagonal transformation
% in the appropriate box in the graphics window. Press
% return or click the the appropriate transformation
% button to perform the transformation. The image of
% the figure under the selected transformation will be
% displayed in the subplot labelled ``Current Image".
% To repeat the same transformation just click the button
% again.
%
% To use your own transformation matrix enter the first row
% by a semicolon or a comma and then enter the second row.
% For example the matrix [1,1; 0,1] can be entered as either
%                 1,1;0,1  or 1,1,0,1
%
% Separate subplots display the initial version of the 
% figure, the current transformed version of the figure,
% and the previous transformed version. 
%
% A Freeze button will copy the current image to a 
% fourth target subplot.
%
% The Undo button will undo the effects of the last 
% transformation that was applied.
%
% The Restart button resets the current and previous 
% image subplots to the initial image. 
%
% The Current Transformation button will display the 
% matrix of the current composite transformation in 
% the MATLAB graphics window. To clear a matrix
% displayed in the graph window, just click on the
% matrix.
%
% The Mystery pull-down menu is used to generate mystery
% transformations. The image of the initial figure under
% the mystery transformation is displayed in the target
% subplot. Mystery transformations are composites of
% rotations, reflections, and diagonal scalings. Angles
% of rotation or reflection are multiples of either 45
% or 60 degrees. The diagonal scaling factors are either
% 1, 2, or 1/2. The level of the mystery transformation
% is the same as the number of composite transformations 
% used in its construction. Level 3 mystery transformations 
% are often difficult to guess. To help, a hint is displayed
% in the MATLAB command window.
% Written by Alex Bondarenko and Steven Leon
% Modified by Emily H. Moore,  May 23, 1996
% Modified by Steven Leon, August 12, 2002
	clc;
	clear;
	%Set up the figure window and four axes for drawing
	%First declare the global variables
global FigH LeftUpH RightUpH LeftBotH RightBotH  FreezeH
	%Figure Window
FigH = figure('MenuBar','none',...  % erase the default menus
	'NumberTitle','off','Name','Transformer',... % name window
	'Units','normalized',...
	'Position',[0.2 0.2 0.7 .6],... 
	'Resize','on',...              % window resize mode on
	'Color','blue');              % set background color to blue
      %  'Position',[0.4 0.2 0.9 .8],... 
      % set window to whole screen
	%Left Upper axes with Initial Image
LeftUpH = axes('Box','on',...
	'Color','black',...
	'NextPlot','add',...
	'Position',[0.3 0.54 0.35 0.39]);
	axis equal, axis square;
	set(gca,'Title',text(0,0,'Initial Image'));
	%Right Upper axes with Target Image
RightUpH = axes('Box','on',...
	'Color','black',...
	'NextPlot','add',...
	'Position',[0.65 0.54 0.35 0.39]);
	axis equal, axis square;
	set(gca,'Title',text(0,0,'Target Image'));
	%Left Bottom axes with Previous Image
LeftBotH = axes('Box','on',...
	'Color','black',...
	'NextPlot','add',...
	'Position',[0.3 0.05 0.35 0.39]);
		axis equal, axis square;
	set(gca,'Title',text(0,0,'Previous Image'));
	%Right Bottom axes with Current Image
RightBotH = axes('Box','on',...
	'Color','black',...
	'NextPlot','add',...
	'Position',[0.65 0.05 0.35 0.39]);
	axis equal, axis square;
	set(gca,'Title',text(0,0,'Current Image'));
	%Set up the image menu at the top of the screen
	%Title of the menu
ImageMenuH = uimenu(FigH,'Label','Image    ');
	%Polygon Image
PolygonH = uimenu(ImageMenuH,'Label','Six-Colored Polygon',...
						'CallBack','imager(1)');
	%Star Image
StarH = uimenu(ImageMenuH,'Label','Four-Colored Star',...
						'CallBack','imager(2)');
PumpH = uimenu(ImageMenuH,'Label','Pumpkin Face',...
						'CallBack','imager(3)');
	%Custom Image
CustomH = uimenu(ImageMenuH,'Label','Custom',...
						'CallBack','imager(4)');
	%Set up the Mystery menu at the top of the screen
	%Title of the menu
MysteryMenuH = uimenu(FigH,'Label','Mystery Game');
	%start level 1 game
Level1H = uimenu(MysteryMenuH,'Label','Level 1',...
						'CallBack','mystery(1)');
Level2H = uimenu(MysteryMenuH,'Label','Level 2',...
						'CallBack','mystery(2)');
Level3H = uimenu(MysteryMenuH,'Label','Level 3',...
						'CallBack','mystery(3)');
QuitMH = uimenu(MysteryMenuH, 'Label','Quit Mystery Game',...
						'CallBack','mystery(4)');
ht   = .055;
wd   = .22;
inc  = .01;
left = .02;
bot  = .61;
wd2  = wd/2;
editcolor = [ .85 .85 .85 ];
	%Set up the "Transformations" menu
							% Frame for menu
TransFrameH = uicontrol(FigH,'Style','frame',...
		'Units','normalized',...
		'Position',[left-inc bot wd+2*inc .36]);
							% Title of menu
TransTextH = uicontrol(FigH,'Style','text',...
		'Units','normalized',...
		'Position',[left bot+4*ht+5*inc wd ht],...
		'String','Transformations');
							% Rotation button
RotationH = uicontrol(FigH,'Style','push',...
		'String','Rotation',...
		'Units','normalized',...
		'Position',[left bot+3*ht+4*inc wd2 ht],...
		'CallBack','trans(1)');
uicontrol( gcf,...
	'Style',        'edit', ...
	'Units',        'normalized', ...
	'Position',     [left+wd2 bot+3*ht+4*inc wd2 ht],...
	'Background',   editcolor,...
	'String',       [],...
	'CallBack',     'trans(1)' )
							% Reflection button
ReflectionH = uicontrol(FigH,'Style','push',...
		'String','Reflection',...
		'Units','normalized',...
		'Position',[left bot+2*ht+3*inc wd2 ht],...
		'CallBack','trans(2)');
uicontrol( gcf,...
	'Style',        'edit', ...
	'Units',        'normalized', ...
	'Position',     [left+wd2 bot+2*ht+3*inc wd2 ht],...
	'Background',   editcolor,...
	'String',       [],...
	'CallBack',     'trans(2)' )
							% Diagonal button
DiagonalH = uicontrol(FigH,'Style','push',...
		'String','Diagonal',...
		'Units','normalized',...
		'Position',[left bot+ht+2*inc wd2 ht],...
		'CallBack','trans(3)');
uicontrol( gcf,...
	'Style',        'edit', ...
	'Units',        'normalized', ...
	'Position',     [left+wd2 bot+ht+2*inc wd2 ht],...
	'Background',   editcolor,...
	'String',       [],...
	'CallBack',     'trans(3)' )
							% Own Tranformation
YourOwnH = uicontrol(FigH,'Style','push',...
		'String','Your Trans.',...
		'Units','normalized',...
		'Position',[left bot+inc wd2 ht],...
		'CallBack','trans(4)');
uicontrol( gcf,...
	'Style',        'edit', ...
	'Units',        'normalized', ...
	'Position',     [left+wd2 bot+inc wd2 ht],...
	'Background',   editcolor,...
	'String',       [],...
	'CallBack',     'trans(4)' )
bot = .03;
							% Frame for "Options"
OptionFrameH = uicontrol(FigH,'Style','frame',...
		'Units','normalized',...
		'Position',[inc bot wd+2*inc .53]);
							% Title of the menu
OptionTextH = uicontrol(FigH,'Style','text',...
		'Units','normalized',...
		'Position',[left bot+7*ht+7*inc wd ht],...
		'String','Options');
							% Undo button
UndoH = uicontrol(FigH,'Style','push',...
		'String','Undo',...
		'Units','normalized',...
		'Position',[left bot+6*ht+6*inc wd ht],...
		'CallBack','options(1)');
							% Restart button
RestartH = uicontrol(FigH,'Style','push',...
		'String','Restart',...
		'Units','normalized',...
		'Position',[left bot+5*ht+5*inc wd ht],...
		'CallBack','options(2)');
							% Freeze button
FreezeH = uicontrol(FigH,'Style','push',...
		'String','Freeze',...
		'Units','normalized',...
		'Position',[left bot+4*ht+4*inc wd ht],...
		'CallBack','options(3)');
							% CurrentT button
CurrentTH = uicontrol(FigH,'Style','push',...
		'String','Current Trans.',...
		'Units','normalized',...
		'Position',[left bot+3*ht+3*inc wd ht],...
		'CallBack','options(4)');
uicontrol( gcf, ...
	'Style',        'push', ...
	'Units',        'normalized',...
	'Position',     [left bot+2*ht+2*inc wd ht],...
	'Background',   editcolor, ...
	'String',       '', ...
	'Tag',          'total',...
	'Visible',      'off',...
	'Callback',     'options(5)' )
uicontrol( gcf, ...
	'Style',        'push', ...
	'Units',        'normalized',...
	'Position',     [left bot+ht+2*inc wd ht],...
	'Background',   editcolor, ...
	'String',       '', ...
	'Tag',          'total',...
	'Visible',      'off',...
	'Callback',     'options(5)' )
							% Quit button
QuitH = uicontrol(FigH,'Style','push',...
		'String','Quit',...
		'Units','normalized',...
		'Position',[left bot+inc wd ht],...
		'CallBack','options(6)');

⌨️ 快捷键说明

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