How to use Camera Views to simulate a real camera
Show older comments
Hello,
I am trying to use Camera Views functions (e.g. campos, camva, etc.) to simulate a real viewing camera, but when I change the parameters it seems not to behave as expected.
For example:
- when I position the camera using campos(), the camera doesn't look like exactly in that position. It looks a bit further.
- when I change the camera view angle with camva(), it looks like a zoom rather than a variation in the camera view angle.
- when I set camtarget() after campos(), the camera position changes and the plot shrinks. Whereas I would only like to keep the camera in the same position, but point it to view another location.
The code I am using is rather simple. It is a dummy code to understand the behaviour of the commands.
surf(peaks);
xlabel('x')
ylabel('y')
zlabel('z')
campos([70 50 15])
camtarget([5 45 0])
Is there anyone with some experience with this functions? How can I simulate a real camera using Camera Views commands?
Thanks,
Fabio
Answers (2)
Mike Garrity
on 12 Jan 2015
Edited: Mike Garrity
on 12 Jan 2015
You need to set the Projection to perspective.
set(gca,'Projection','perspective')
The default is orthographic, which is kind of like an infinitely long telephoto lens.
As you can see, the default CameraViewAngle is awfully wide in this case.

Turning it down to something like 35 looks a lot better.
camva(35)

Fabio
on 13 Jan 2015
0 votes
1 Comment
Mike Garrity
on 13 Jan 2015
I'm not sure I follow.
The camera's viewport is rasterized to a fixed number of pixels. As you decrease the view angle, that viewport covers a smaller area in the model. Therefore, the resolution at which the model is rasterized increases.
But if you have a texturemap on the model, then the number of texels isn't going to be affected by the camera view angle.
I'd probably need to know more about your case to give a sensible answer.
Categories
Find more on Camera Views in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!