Class: Optical::Lens
- Inherits:
-
Object
- Object
- Optical::Lens
- Defined in:
- lib/optical/lens.rb
Overview
A representation of a simple thin lens en.wikipedia.org/wiki/Lens_(optics)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#center_thickness ⇒ Object
readonly
Returns the value of attribute center_thickness.
- #clear_diameter ⇒ Object (also: #clear_aperture) readonly
- #clear_radius ⇒ Object readonly
- #diameter ⇒ Object
-
#edge_thickness ⇒ Number
The thickness of the Lens at its edge.
-
#focal_length ⇒ Object
readonly
Returns the value of attribute focal_length.
- #numerical_aperture ⇒ Object readonly
- #radius ⇒ Object readonly
- #thickness ⇒ Object
Instance Method Summary collapse
-
#initialize(**options) ⇒ Lens
constructor
A new instance of Lens.
Constructor Details
#initialize(**options) ⇒ Lens
Returns a new instance of Lens.
9 10 11 |
# File 'lib/optical/lens.rb', line 9 def initialize(**) .each {|k,v| respond_to?(k) ? instance_variable_set("@#{k}", v) : raise(ArgumentError, "Unknown argument: '#{k}'") } end |
Instance Attribute Details
#center_thickness ⇒ Object (readonly)
Returns the value of attribute center_thickness.
28 29 30 |
# File 'lib/optical/lens.rb', line 28 def center_thickness @center_thickness end |
#clear_diameter ⇒ Object (readonly) Also known as: clear_aperture
15 16 17 |
# File 'lib/optical/lens.rb', line 15 def clear_diameter @clear_diameter || (2*@clear_radius) end |
#clear_radius ⇒ Object (readonly)
22 23 24 |
# File 'lib/optical/lens.rb', line 22 def clear_radius @clear_radius || (@clear_diameter && @clear_diameter/2) end |
#diameter ⇒ Object
32 33 34 |
# File 'lib/optical/lens.rb', line 32 def diameter @diameter || 2*@radius end |
#edge_thickness ⇒ Number
Returns the thickness of the Optical::Lens at its edge.
38 39 40 |
# File 'lib/optical/lens.rb', line 38 def edge_thickness @edge_thickness end |
#focal_length ⇒ Object (readonly)
Returns the value of attribute focal_length.
7 8 9 |
# File 'lib/optical/lens.rb', line 7 def focal_length @focal_length end |
#numerical_aperture ⇒ Object (readonly)
42 43 44 |
# File 'lib/optical/lens.rb', line 42 def numerical_aperture Math.sin(Math.atan2(clear_radius || radius, focal_length)) end |
#radius ⇒ Object (readonly)
48 49 50 |
# File 'lib/optical/lens.rb', line 48 def radius @radius || @diameter/2 end |
#thickness ⇒ Object
54 55 56 |
# File 'lib/optical/lens.rb', line 54 def thickness [@center_thickness, @edge_thickness].max end |