Method: Joules.refractive_index_v2

Defined in:
lib/joules/waves.rb

.refractive_index_v2(critical_angle) ⇒ Float

Note:

There is one other method for calculating refractive index.

Calculates the refractive index of a substance given critical angle.

Examples:

Joules.refractive_index_v2(48.7535) #=> 1.3299993207924483

Parameters:

  • critical_angle (Int, Float)

    critical_angle != 0; critical_angle is in degrees

Returns:

  • (Float)

Raises:

  • (ZeroDivisionError)

    if critical_angle = 0



145
146
147
148
149
150
151
# File 'lib/joules/waves.rb', line 145

def refractive_index_v2(critical_angle)
  if critical_angle.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return 1.0 / Math.sin(to_radians(critical_angle))
  end
end