Borrar filtros
Borrar filtros

patch object changes size when rotating with makehgtform in 2014b

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Mike Garrity
Mike Garrity el 4 de Dic. de 2015
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 comentario
Mike Garrity
Mike Garrity el 4 de Dic. de 2015
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by