class Optical::Lens

A representation of a simple thin lens en.wikipedia.org/wiki/Lens_(optics)

Attributes

center_thickness[R]

@!attribute [r] center_thickness

@return [Number]  the thickness of the {Lens} at its center
edge_thickness[RW]

@!attribute [r] edge_thickness

@return [Number]  the thickness of the {Lens} at its edge
focal_length[R]

@!attribute [r] focal_length

@return [Number]  the distance from the principal plane to the focal point

Public Class Methods

new(**options) click to toggle source
# File lib/optical/lens.rb, line 9
def initialize(**options)
    options.each {|k,v| respond_to?(k) ? instance_variable_set("@#{k}", v) : raise(ArgumentError, "Unknown argument: '#{k}'") }
end

Public Instance Methods

clear_aperture()
Alias for: clear_diameter
clear_diameter() click to toggle source

@!attribute [r] clear_diameter

@return [Number]  the diameter of the portion of the {Lens} that meets its stated specifications
# File lib/optical/lens.rb, line 15
def clear_diameter
    @clear_diameter || (2*@clear_radius)
end
Also aliased as: clear_aperture
clear_radius() click to toggle source

@!attribute [r] clear_radius

@return [Number]  the radius of the portion of the {Lens} that meets its stated specifications
# File lib/optical/lens.rb, line 22
def clear_radius
    @clear_radius || (@clear_diameter && @clear_diameter/2)
end
diameter() click to toggle source

@!attribute diameter

@return [Number]  the physical diameter of the {Lens}
# File lib/optical/lens.rb, line 32
def diameter
    @diameter || 2*@radius
end
numerical_aperture() click to toggle source

@!attribute [r] numerical_aperture

@return [Number]  the numerical aperture of the lens, based on clear_radius (if set; otherwise it's based on radius)
# File lib/optical/lens.rb, line 42
def numerical_aperture
    Math.sin(Math.atan2(clear_radius || radius, focal_length))
end
radius() click to toggle source

@!attribute [r] radius

@return [Number]   the physical radius of the {Lens}
# File lib/optical/lens.rb, line 48
def radius
    @radius || @diameter/2
end
thickness() click to toggle source

@!attribute thickness

@return [Number]  the maximum thickness of the {Lens}
# File lib/optical/lens.rb, line 54
def thickness
    [@center_thickness, @edge_thickness].max
end