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 "
$lens_focal_length_mm millimeterswill do the job on a Nikon or Canon or similar 35mm camera
|
Source of formula: Kodak
Professional Photoguide
Source Code for this page: http://philip.greenspun.com/seia/examples-basics/focal-length.txt