Camera and view function and properties
Show older comments
I've been trying to understand the view and camera functions and created the following code for illustration:
peaks(30);
ax=get(gca);
% Display values
disp('Initial values')
dispprops(ax)
% Change target
ax.CameraTarget = [0 0 10];
disp('Target changed by property')
dispprops(ax)
camtarget([0 0 20])
disp('Target changed by function')
dispprops(ax)
% Change position
ax.CameraPosition = [-30 -40 70];
disp('Position changed by property')
dispprops(ax)
campos([-30 -40 80])
disp('Position changed by function')
dispprops(ax)
% Change view
ax.View = [45 90];
disp('View changed by property')
dispprops(ax)
view([60 60])
disp('View changed by function')
dispprops(ax)
function dispprops(ax)
viewfromax = ax.View %#ok
[azfromfun,elfromfun] = view;
disp(['viewfromfun = ' num2str(azfromfun) ',' num2str(elfromfun)])
posfromax = ax.CameraPosition %#ok
disp(['posfromfun = ' num2str(campos)])
targetfromax = ax.CameraTarget %#ok
disp(['targetfromfun = ' num2str(camtarget)])
end
There are two things that seem odd to me:
1) Changes via the ax properties are stored, but don't do anything in the plot (even if the respective modes are set to manual). On the other hand, changes via functions are not stored in the properties, but do modify the plot. So what are the properties actually good for?
2) Changes to position and target do not change the view values, but view on the other hand does change target and position. Shouldn't the dependency be mutual? I. e. aren't azimuth and elevation determined by camera position and target (since target and position are independent from each other, c. f. https://mathworks.com/help/matlab/creating_plots/defining-scenes-with-camera-graphics.html)?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!


