Method: Joules.focal_length
- Defined in:
- lib/joules/waves.rb
.focal_length(object_distance, image_distance) ⇒ Float
Calculates the focal length of a lens given object distance and image distance.
181 182 183 184 185 186 187 |
# File 'lib/joules/waves.rb', line 181 def focal_length(object_distance, image_distance) if object_distance.zero? || image_distance.zero? raise ZeroDivisionError.new('divided by 0') else return 1 / ((1.0 / object_distance) + (1.0 / image_distance)) end end |