Making sense of the Camera View Angle behavior in 3d plots

5 views (last 30 days)
I'm currently working on a GUI application that requires a mapping of 3d axis coordinates to figure coordinates. As it now stands, the calibration step requires knowledge of the current zoom level, as normally determined by the 'CameraViewAngle' property of the axes. As I understand, when the 'CameraViewAngleMode' is set to 'auto', MATLAB calculates the appropriate 'CameraViewAngle' so as to fit the data entirely within the axes. However, there seems to be an issue when 3d rotations are enabled (via the figure toolbar), that I suspect has to do with the way MATLAB transitions between '2D' and '3D' views. Here is a simple example:
hFig = figure('Name', 'Cursor Movement Test', 'NumberTitle', 'off', 'units', 'points', 'toolbar', 'figure');
hPanel = uipanel('Parent', hFig, 'Position', [.2 .3 .6 .5], 'BackgroundColor', [.9 .9 1]);
hAx = axes('Parent', obj.hPanel,...
'Units' , 'normalized',...
'Position', [0 0 1 1],...
'XLim' , [0 50],...
'YLim' , [10 45],...
'ZLim' , [-30 30]);
hSurf = surface(peaks);
grid on
xlabel('x');
ylabel('y');
zlabel('z');
set(hAx, 'DataAspectRatio', [3 1 1]);
Initially, the surface is displayed as a 2D view (z-axis pointing out of the screen):
The 'CameraViewAngle' is returned as:
get(gca,'CameraViewAngle')
ans =
5.6101
Then, I switch to 3d rotation mode via the figure toolbar, and rotate the plot clockwise by 90 degrees (again, the plot is still displayed as a 2D view with the z-axis pointing out of the screen). The plot then looks like this:
However, I still find that:
get(gca,'CameraViewAngle')
ans =
5.6101
All other axes properties remain unchanged as well. In other words, some type of zooming has occurred automatically that is not reflected by any of the axes properties! Similarly, if I then select the zoom tool from the figure toolbar, and try and zoom on this rotated plot (via a single click), I see very odd behavior:
I imagine that these unexpected behaviors are related to how MATLAB treats '2D' vs. '3D' plots, but any insights or explanations would be highly appreciated! For completeness, this example was done using MATLAB_R2011b, on a Mac laptop running OSX 10.6.8.

Answers (0)

Categories

Find more on 3-D Scene Control in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!