2010-05-31 75 views
2

我正在使用matlab來可視化一個場景。爲了放大場景,我可以通過eather來做到這一點: - 修復攝影機位置和攝像頭,並更改cameraviewangle或 - 修復cameratarget和攝像頭視角並沿着視線移動攝像頭(由cameraPosition和cameraTarget)。Matlab如何計算攝像機視角?

我知道如何設置攝像機位置CameraTarget和viewangle的值,但我不知道如何定義最佳視角。在攝像頭視角的自動模式下,matlab計算捕獲所有攝像頭位置所有場景的最小視角。我感謝任何幫助理解這一點。

伊曼

回答

0

我可簡單化這一點,但它不應該歸結爲幾何?如果攝像機的位置與場景相對,則應該能夠使用場景的寬度來確定包含所有場景的角度。

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

所以從:例如,如果你的寬度「W」的場景是距離「d」從相機而在直角觀察遠,所需的最小視場角能使用正弦定理衍生圖片:

alt text

您的相機將被放置在C和場景寬度「W」是線段AB。從相機到場景的距離'd'是線段CD,最小視角爲ACB。

1

在MATLAB中,相機視角與「變焦」功能基本相同,因爲沒有透視失真。視角越小,圖像越有效地被放大,因爲視口被放大以適應數字窗口的大小。

The documentation of 'camva'包括這個例子創建了兩個按鈕來放大/縮小場景:

% 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); 

所以,如果你要放大,調整視角。如果您想自動「縮放」以適合整個場景,請設置:

camva('auto'); 
相關問題