#### Topic: Photography Methods

Any comments, corrections, refactorings or suggestions would be fantastic, thanks.

Hopefully we might have some photography nuts out there too

# camera related

def frame_diagonal(frame_horizontal, frame_vertical)

@frame_diagonal = Math.sqrt((frame_horizontal**2) + (frame_vertical**2))

enddef focal_length_multiplier(frame_diagonal_1, frame_diagonal_2)

@focal_length_multiplier = frame_diagonal_1 / frame_diagonal_2

enddef circle_of_confusion(frame_diagonal)

@circle_of_confusion = frame_diagonal / 1730

end# lens related

def hyperfocal_distance(focal_length, f_number, circle_of_confusion)

@hyperfocal_distance = ((focal_length**2) / (f_number * circle_of_confusion)) + focal_length

enddef near_distance(focus_distance, hyperfocal_distance, focal_length)

@near_distance = (focus_distance * (hyperfocal_distance - focal_length)) / (hyperfocal_distance + focus_distance - 2 * focal_length)

enddef far_distance(focus_distance, hyperfocal_distance, focal_length)

@far_distance = (focus_distance * (hyperfocal_distance - focal_length)) / (hyperfocal_distance - focus_distance)

enddef total_distance(near_distance, far_distance)

@total_distance = far_distance - near_distance

enddef magnification(focal_length, focus_distance)

@magnification = focal_length/(focus_distance - focal_length)

enddef fov_rectilinear_horizontal(frame_horizontal, focal_length, magnification)

@fov_rectilinear = 2 * Math.arctan(frame_horizontal/(focal_length * 2 * (magnification+1)))

enddef fov_rectilinear_vertical(frame_vertical, focal_length, magnification)

@fov_rectilinear = 2 * Math.arctan(frame_vertical/(focal_length * 2 * (magnification+1)))

enddef fov_rectilinear_diagonal(frame_diagonal, focal_length, magnification)

@fov_rectilinear = 2 * Math.arctan(frame_diagonal/(focal_length * 2 * (magnification+1)))

enddef f_number_to_aperture_diameter(focal_length, f_number)

@aperture_diameter = focal_length / f_number

end# exposure related

def exposure_value(f_number, shutter_speed)

@exposure_value = Math.logn(2, (f_number**2 / shutter_speed))

end# math related

def Math.logn(x, n)

Math.log(x) / Math.log(n)

enddef Math.arctan(x)

Math.atan2(x, 1.0)

end