필터 지우기
필터 지우기

patch object changes size when rotating with makehgtform in 2014b

조회 수: 5 (최근 30일)
lou
lou 2015년 12월 4일
댓글: Mike Garrity 2015년 12월 4일
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