patch object changes size when rotating with makehgtform in 2014b

5 次查看(过去 30 天)
Hello,
I have written my initial matlab script in matlab 2013b and now in 2014b version it does not work as I would expect.
I created a 3d object with patch function and I am using makehgtform for rotating it. When I am rotating it in matlab 2014b then it gets with some rotations bigger or smaller. This did not happen in MatLab 2013b.
I created the patch object like this -
vert = [-0.5 -0.5 0; -0.5 0.5 0; 0.5 0.5 0; 0.5 -0.5 0 ; ...
-0.5 -0.5 1;-0.5 0.5 1 ; 0.5 0.5 1 ;0.5 -0.5 1];
fac = [1 2 3 4; ...
2 6 7 3; ...
4 3 7 8; ...
1 5 8 4; ...
1 2 6 5; ...
5 6 7 8];
c(1)=patch('Faces',fac,'Vertices',vert,'FaceColor','w'); % patch function
....
t = hgtransform('Parent',ax);
set(c,'Parent',t)
that's only a part of it.
the figure settings are the following
f=figure('units','normalized','outerposition',[0 0 1 1], 'ToolBar', 'none');
set(gcf,'Resize','off')
ax=axes('xlim', [-1.7 1.7], 'ylim', [-1.7 1.7], 'zlim', [-1.7 1.7]);
view([ 0 0]);
grid off;
axis image;
axis off;
I already tried set(gcf,'Resize','off'), but this does not work. Has anyone an idea why is it scaling/resizing? and how I could fix it?

采纳的回答

Mike Garrity
Mike Garrity 2015-12-4
It's the call to 'axis image'. I'll have to do some digging to figure out what changed there, but what are you trying to accomplish with it? It's really meant for setting things up to draw images in 2D. Perhaps you could use 'axis ij' instead if you just want to reverse the YDir?
  1 个评论
Mike Garrity
Mike Garrity 2015-12-4
Ah, I see the difference.
Axis image calls axis tight. The behavior of 'axis tight' changed in R2014b. You can see the difference with this example:
t = linspace(0,2*pi,150);
r = rand;
x = r*cos(t);
y = r*sin(t);
h = plot(x,y);
axis tight
for i=1:length(t)
set(h,'XData',1-cos(t(i)) + x, ...
'YData', sin(t(i)) + y)
drawnow
end
Before 14b, this calculated the tight limits at the time you called 'axis tight', and set them to manual mode. They never changed after that. That was considered a bug, and we finally fixed it in 14b. Now axis tight puts the axes in a mode where the limits stay tight as the object moves around.
My guess that you probably want something like this, if you're rotating objects in 3D.
axis ij vis3d off
That says to reverse the YDir, make the DataAspectRatio [1 1 1], and hide the rulers.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by