How can I rotate camera keeping the size of sphere constant?

조회 수: 13 (최근 30일)
Gonzalo Ferrada
Gonzalo Ferrada 2020년 11월 5일
답변: Tim 2020년 11월 5일
I am plotting a sphere (world) that later I rotate using the built-in function view. This works well and allows to rotate the sphere the way I want in a loop to save individual frames. But the problem is that at each rotation, the size of the sphere changes (see animation attached). My ultimate goal is to create a nice animation but the changing size of the sphere is annoying.
My question then is: Is there a way that I can rotate the camera view but keep the same sphere size in each frame? Perhaps, another function similar to view? or another kind of workaround?
This is how I am creating the sphere:
I = imread('myimage.png');
[x,y,z] = sphere(359);
surface(x,y,z, 'FaceColor','texturemap','EdgeColor','none','Cdata',flipud(I))
daspect([1 1 1])
After that, I plot the data that I want.
I have also tried using:
set(gca,'Position',[0 0 1 1])
axis tight
and it does not work for my purpose.
  댓글 수: 3
Adam Danz
Adam Danz 2020년 11월 5일
편집: Adam Danz 2020년 11월 5일
Tim's comment is the answer (Tim, consider moving it to the answers section).
[x,y,z] = sphere(359);
surface(x,y,z, 'FaceColor','texturemap','EdgeColor','none')
axis vis3d
grid on
xlabel('x'); ylabel('y'); zlabel('z')
rotate3d on
Gonzalo Ferrada
Gonzalo Ferrada 2020년 11월 5일
Great! This solves the problem. Thank you guys!

댓글을 달려면 로그인하십시오.

채택된 답변

Tim 2020년 11월 5일
axis vis3d
See Adam's comment above for a demo script; for completeness sake this same question was answered here by Xiaofan Fei.

추가 답변 (0개)


Help CenterFile Exchange에서 MATLAB Support Package for USB Webcams에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by