![](https://i-blog.csdnimg.cn/blog_migrate/c57487ef0d0d6a9da614c5e19c83b6fe.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/552f843a7d5f3fa261fcc0cbb30b3568.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/adeefbc382b52f98131b43746f467632.jpeg)
function [ f ] = compute_focal_length( d_ref, f_ref, pos )
%% Compute camera focal length with given camera position.
%
% In this function, multiple camera positions will be given. The camera is
% placed on z axis and thus only z axis for the camera position is given.
% We'll need to compute corresponding focal length to achieve Dolly Zoom
% effect for each camera position.
%
% Input:
% - d_ref: 1 by 1 double, distance of the object whose size remains constant
% - f_ref: 1 by 1
%% Compute camera focal length with given camera position.
%
% In this function, multiple camera positions will be given. The camera is
% placed on z axis and thus only z axis for the camera position is given.
% We'll need to compute corresponding focal length to achieve Dolly Zoom
% effect for each camera position.
%
% Input:
% - d_ref: 1 by 1 double, distance of the object whose size remains constant
% - f_ref: 1 by 1