MATLAB Answers

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

2 views (last 30 days)
Gonzalo Ferrada
Gonzalo Ferrada on 5 Nov 2020
Answered: Tim on 5 Nov 2020
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))
view(3)
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])
and/or:
axis tight
and it does not work for my purpose.
Thanks!
  3 Comments

Sign in to comment.

Accepted Answer

Tim
Tim on 5 Nov 2020
Use:
axis vis3d
See Adam's comment above for a demo script; for completeness sake this same question was answered here by Xiaofan Fei.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!