Method: Joules.refractive_index_v1

Defined in:
lib/joules/waves.rb

.refractive_index_v1(angle_of_incidence, angle_of_refraction) ⇒ Float

Note:

There is one other method for calculating refractive index.

Calculates the refractive index of a substance given angle of incidence and angle of refraction.

Examples:

Joules.refractive_index_v1(50, 35) #=> 1.3355577296591308

Parameters:

  • angle_of_incidence (Int, Float)

    angle_of_incidence is in degrees

  • angle_of_refraction (Int, Float)

    angle_of_refraction != 0; angle_of_refraction is in degrees

Returns:

  • (Float)

Raises:

  • (ZeroDivisionError)

    if angle_of_refraction = 0



128
129
130
131
132
133
134
135
# File 'lib/joules/waves.rb', line 128

def refractive_index_v1(angle_of_incidence, angle_of_refraction)
  if angle_of_refraction.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return Math.sin(to_radians(angle_of_incidence)) /
           Math.sin(to_radians(angle_of_refraction))
  end
end