How to change the camera position and view angle?

조회 수: 66 (최근 30일)
john
john 2013년 4월 18일
I am doing a structured light simulation. I need to look at a 3d object at different angle.The object does move,only camera moves. So I use
view([0 90]);
CameraPosition=([100 5000 2000]);
but it seems won't work;How can I set the camera position and direction easily?
%This program is to simulate different discontinuity and its struct light
%image
clear;clc;close all;
X=[0:0.4:200];
Y=[0:0.4:100];
[x,y]=meshgrid(X,Y);
M=length(X);
N=length(Y);
z=zeros(N,M);
%z(find(X<60))=0;
Mid1=fix(M/4);
Mid2=fix(M/2);
for k=Mid1:Mid2
z(:,k)=z(:,k)+0.1*(k-Mid1);
end
for k=Mid2+1:M
z(:,k)=z(:,k)+0.1*(Mid2-Mid1);
end
figure(1);
mesh(x,y,z)
f0=0.02;
I1=cos(2*pi*f0*x);
I2=cos(2*pi*f0*x+z);
figure(2);
subplot(2,1,1);
imshow(I1);
subplot(2,1,2);
imshow(I2);
figure(3);
colormap(Gray);
mesh(x,y,z,I2);
view([0 90]);
CameraPosition=([100 5000 2000]);

답변 (1개)

Jan
Jan 2013년 4월 18일
You do not set the camera position, but only assign a value to a variable, which is called CameraPosition. Of course this does not change anything in the graphics. Try:
set(gca, 'CameraPosition', [100 5000 2000]);

카테고리

Help CenterFile Exchange에서 Camera Views에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by