Relationship between FOV and Camera Position

Hi,

Im trying to automatically adjust my Camera Z Position so that when I change my FOV, the overall size of my object is maintained while the “warp” of the object changes. Is there a mathematical relationship to do this. Has anyone already done anything like this?

Any help would be appreciated

Thanks,
Vishant

old FOV = f
new FOV = f’
old z distance to object in focus = z
new z distance to object in focus = z’

z’ = z * tan(f/2) / tan(f’/2)