Search code examples
matlabmatlab-figurecomputational-geometryprojectionangle

Perspective control in MATLAB 3D figures


How to change the vanishing points (P1,P2,P3) in the perspective in MATLAB 3D figures? Below there is a scheme of explanation what I mean:

enter image description here

Thanks in advance for your help.


Solution

  • If you want to control the perspective appearance in a plot, you'll want to first change the Projection property of the axes to perspective. Then you can change the various camera properties of the axes to get the view you want. The important ones for adjusting how the perspective looks are the CameraViewAngle and CameraPosition.

    I have found that a "realistic" perspective view can be achieved using a CameraViewAngle of about 30 degrees, mimicking the preferred viewing area of the human eye:

    enter image description here

    The default CameraViewAngle is about 6.6, so setting it to 30 will cause the view to appear zoomed-out. You will then want to change the CameraPosition so that it is closer to the CameraTarget, thus zooming the view back in. You can use a larger CameraViewAngle if you want a more exaggerated perspective (like a fisheye lens).