Questions about setting the aspect ratio when rotating an object

4 views (last 30 days)
Hi all,
I was playing with the Utah teapot functions before and I want to generate a rotating teapot. I want to rotate the tea pot every one degree so I modified the viewpoint after generating the teapot. The teapot was like this at first -
But when I used
axis vis3d
The teapot was squeezed and was like this -
I also checked the rotating Utah teapot in Psychtoolbox and I found out that the teapot wasn't squeezed when rotating (I'm not quite sure how to render image from openGL-PTB yet) so that I wonder if I could do something similar in MATLAB. Thank you!
-Xixi

Accepted Answer

Mike Garrity
Mike Garrity on 9 Oct 2015
What 'axis vis3d' does is freeze the aspect ratios at their current values. This is useful if you're going to rotate the object, because otherwise MATLAB will keep computing new aspect ratios for each frame.
But in a case like this, you might want a particular aspect ratio, rather than the one that MATLAB computed on the first frame. In that case you're going to want to set the aspect ratio, instead of just freezing the one you have. There are a couple of options here.
If you look at "teapotdemo", you'll see that it does this:
daspect([1 1 1])
That means that it should make the scale factors it's using for each of the X, Y, & Z directions be exactly the same. The result looks like this:
That's probably what you want here. But if you rotate it, you'll see that it still jumps around a bit. That's because the axes is still trying to take as much of the figure as possible, and it'll keep adjusting things like the limits, even if it can't adjust the scales.
So another option is this:
axis equal
This does the same thing as daspect([1 1 1]), but it also locks the limits and "plot box" down. The result looks similar:
But there's even less jumping as you rotate it around.
Does that make sense?

More Answers (0)

Community Treasure Hunt

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

Start Hunting!