Method: Joules.power_of_lens

Defined in:
lib/joules/waves.rb

.power_of_lens(focal_length) ⇒ Float

Calculates the power of a lens given focal length.

Examples:

Joules.power_of_lens(2) #=> 0.5

Parameters:

  • focal_length (Int, Float)

    focal_length > 0; focal_length is in metres

Returns:

  • (Float)

    return value > 0; return value is in dioptres

Raises:

  • (ZeroDivisionError)

    if focal_length = 0



197
198
199
200
201
202
203
# File 'lib/joules/waves.rb', line 197

def power_of_lens(focal_length)
  if focal_length.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return 1.0 / focal_length
  end
end