How to change the camera position and view angle?
55 views (last 30 days)
Show older comments
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]);
0 Comments
Answers (1)
Jan
on 18 Apr 2013
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]);
0 Comments
See Also
Categories
Find more on Camera Views in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!