2016-08-31 4 views
0

私は陰影をつけた3-Dオブジェクトの3次元プロットを持っています。ユーザーがプロットを回転させたとき、光源を常にユーザーが見ている方向から更新するようにしますか?Matlab:Moving Light Source

答えて

0

MATLABのcamlightコマンド(online documentation)をご覧ください。

ここであなたが始めるために、最小限のデモです:

function camlight_demo 
    % some example data to plot 
    surf(peaks); 
    h = rotate3d; 
    set(h,'Enable','on'); 

    % add a light 
    LightSource = camlight('headlight'); 

    % add a callback which will be executed after each rotation 
    set(h,'ActionPostCallback',{@move_light_source, LightSource}); 
end 

% This function will move the light after each rotation 
function move_light_source(src, evt, LightSource) 
    camlight(LightSource, 'headlight'); 
end