Why am I unable to rotate an image object using the HGTRANSFORM function in MATLAB 7.0 (R14)?

3 views (last 30 days)
I create an image in an hgtransform object. When I try to rotate the hgtransform object 90 degrees, I expect the image to rotate 90 degrees. Instead of rotating, the image is distorted as it translates across the axes. The following code reproduces the issue:
load clown
a = axes('XLim',[-150 150],'YLim',[-150 150]);
h = hgtransform('Parent',a);
colormap(map)
image('CData',X, ...
'Parent',h, ...
'XData',[0 100], ...
'YData',[100 0]);
for r = 0:1:90
T = makehgtform('zrotate',r*pi/180);
set(h,'Matrix',T);
pause(0.1);
drawnow
end

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
Documentation on the HGTRANSFORM function is missing the following information:
The object within the hgtransform needs to be a true 3-dimensional object for the rotation transform to produce the desired effect. The image is not a true 3-dimensional object. If a 3-dimensional transform is applied, the image is resized to fit a 2-dimensional projection of the hgtransform.
Only a true 3-dimensional object (i.e. a surface object) can be transformed correctly in a hgtransform object:
load clown
a = axes('XLim',[-150 150],'YLim',[-150 150]);
h = hgtransform('Parent',a);
colormap(map)
surface(ones(100),flipud(X),...
'FaceColor','texturemap',...
'EdgeColor','none',...
'CDataMapping','direct',...
'Parent', h)
for r = 0:1:90
T = makehgtform('zrotate',r*pi/180);
set(h,'Matrix',T);
pause(0.1);
drawnow
end

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!