Method: Joules.magnification

Defined in:
lib/joules/waves.rb

.magnification(image_height, object_height) ⇒ Float

Calculates the magnification given image height and object height.

Examples:

Joules.magnification(10, 5) #=> 2.0

Parameters:

  • image_height (Int, Float)

    image_height >= 0; image_height is in a unit of length

  • object_height (Int, Float)

    object_height > 0; object_height has the same units as image_height

Returns:

  • (Float)

    return value >= 0

Raises:

  • (ZeroDivisionError)

    if object_height = 0



163
164
165
166
167
168
169
# File 'lib/joules/waves.rb', line 163

def magnification(image_height, object_height)
  if object_height.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return image_height / object_height.to_f
  end
end