Last active
October 22, 2016 05:54
-
-
Save albertosaurus/601c93851bd31e99d024625d14acb542 to your computer and use it in GitHub Desktop.
Ruby script to calculate actual focal length at minimum focusing distance (mm) and max reproduction ratio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pretty much all consumer lenses suffer from focus breathing at close distances, i.e the focal length changes. | |
# This lets us calculate the max focal length of a given lens at minimum focusing distance. | |
# | |
# Example 1: Nikon 70-200 f2.8 VR II - minimum focusing distance is 1.4m, max reproduction ratio is 0.12x. | |
# | |
# compute_focal_length 1400, 0.12 | |
# => 133.92857142857142 | |
# | |
# So at close distances, the Nikon isn't a 200mm lens, it's more like 135mm. | |
# | |
# Example 2: Canon 70-200 f2.8 L IS II - minimum focusing distance is 1.2m, max reproduction ratio is 0.21x. | |
# | |
# compute_focal_length 1200, 0.21 | |
# => 172.11939075199783 | |
# | |
# Thus, at close distances the Canon isn't 200mm either, it's more like 175mm. | |
# | |
# @param minimum_focusing_distance_mm [Numeric] minimum focusing distance in mm (so 1.4m is 1400mm) | |
# @param max_reproduction_ratio [Numeric] maximum reproduction ratio | |
# | |
# @return [Numeric] | |
def compute_focal_length(minimum_focusing_distance_mm, max_reproduction_ratio) | |
nodal_point = minimum_focusing_distance_mm / (1 + 1 / max_reproduction_ratio) | |
1 / ( 1 / nodal_point + 1 / (minimum_focusing_distance_mm - nodal_point) ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment