set_form_variables # distance_in_feet, subject_size_in_feet are the args from the form # they are now set in Tcl local variables thanks to the magic # utility function call above # let's do a little IBM mainframe-style error-checking here if { ![info exists distance_in_feet] || [string compare $distance_in_feet ""] == 0 } { ns_return 200 text/plain "Please fill in the \"distance to subject\" field" # stop the execution of this script return } if { ![info exists subject_size_in_feet] || [string compare $subject_size_in_feet ""] == 0 } { ns_return 200 text/plain "Please fill in the \"subject size\" field" # stop the execution of this script return } # we presume that subject is to fill a 1.5 inch long-dimension of a # 35mm negative # ahhh... the joys of arithmetic in Tcl, a quality language so # much cleaner than Lisp set distance_in_inches [expr $distance_in_feet * 12] set subject_size_in_inches [expr $subject_size_in_feet * 12] set magnification [expr 1.5 / $subject_size_in_inches] set lens_focal_length_inches [expr $distance_in_inches / ((1/$magnification) + 1)] set lens_focal_length_mm [expr round($lens_focal_length_inches * 25.4)] # now we return a page to the user, one big string into which we let Tcl # interpolate some variable values ns_return 200 text/html " You need $lens_focal_length_mm mm
\"100th

$lens_focal_length_mm millimeters

will do the job on a Nikon or Canon or similar 35mm camera


Here are the raw numbers: Assumptions: You are using a standard 35mm frame (24x36mm) whose long dimension is about 1.5 inches. You are holding the camera in portrait mode so that your subject is filling the long side of the frame. You are supposed to measure subject distance from the optical midpoint of the lens, which for a normal lens is roughly at the physical midpoint.

Source of formula: Kodak Professional Photoguide
Source Code for this page: http://philip.greenspun.com/seia/examples-basics/focal-length.txt

Bored? Try again

How far away is your subject? (in feet)

How high is the object you want to fill the frame? (in feet)


philg@mit.edu
"