Class: Optical::PlanoConvexLens

Inherits:
Lens
  • Object
show all
Defined in:
lib/optical/plano_convex_lens.rb

Overview

A representation of a plano convex lens

Instance Attribute Summary collapse

Attributes inherited from Lens

#center_thickness, #clear_diameter, #clear_radius, #diameter, #edge_thickness, #focal_length, #numerical_aperture, #radius

Method Summary

Methods inherited from Lens

#initialize

Constructor Details

This class inherits a constructor from Optical::Lens

Instance Attribute Details

#radius_of_curvatureObject

Returns the value of attribute radius_of_curvature.



8
9
10
# File 'lib/optical/plano_convex_lens.rb', line 8

def radius_of_curvature
  @radius_of_curvature
end

#thicknessObject

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/optical/plano_convex_lens.rb', line 13

def thickness(_radius=nil, **options)
    return super() if !_radius && options.empty?

    _radius ||= options[:radius] || (options[:diameter]/2)

    raise ArgumentError, "Requested radius (#{_radius}) is outside of the lens" if _radius > radius

    if _radius && center_thickness && radius_of_curvature
	center_thickness - radius_of_curvature + Math.sqrt(radius_of_curvature**2 - _radius**2)
    end
end