tags:

views:

60

answers:

2

I am using matlab to visualise a scene. In order to zoom in the scene, I can do that by eather: - Fix the cameraposition and the cameratarget and change the cameraviewangle.or - Fix the cameratarget and the cameraview angle and moving the camera along the viewing line (defined by the cameraPosition and the cameraTarget).

I know how to set the values of cameraposition CameraTarget and viewangle, but I do not how to define the optimal view angle. In auto mode of cameraviewangle, matlab calculate the smalest view angle that capture all the scene from the specefied camera position. I appreciate any help in understanding this.

Iman

A: 

I may be oversimplifying this, but shouldn't it boil down to geometry? If you have the location of your camera relative to your scene, you should be able to use the width of the scene to determine the angle necessary to include all of it. For example, if your scene of width 'w' is distance 'd' away from your camera while viewed at a right angle, the minimum viewing angle required can be derived using the law of sines:

alpha=arcsin(w/sqrt(d^2+(w/2)^2))

So from the image:

alt text

Your camera would be positioned at C, and your scene width 'w' would be the line segment AB. The distance 'd' from your camera to your scene would be the line segment CD, and the minimum viewing angle would be ACB.

Doresoom
A: 

In MATLAB the camera view angle is basically the same as a "zoom" function because there is no perspective distortion. The smaller the view angle, the more the image is effectively magnified because the viewport is enlarged to fit the size of the figure window.

The documentation of 'camva' includes this example which creates two push-buttons to zoom in/out of a scene:

% Set the range checking in the callback statements to keep
% the values for the camera view angle in the range greater 
% than zero and less than 180.
uicontrol('Style','pushbutton',...
  'String','Zoom In',...
  'Position',[20 20 60 20],...
  'Callback','if camva <= 1;return;else;camva(camva-1);end');
uicontrol('Style','pushbutton',...
  'String','Zoom Out',...
  'Position',[100 20 60 20],...
  'Callback','if camva >= 179;return;else;camva(camva+1);end');
% Now create a graph to zoom in and out on:
surf(peaks);

So if you want to zoom, adjust the view angle. If you want to automatically "zoom" to fit the entire scene, set:

camva('auto');
scomar

related questions