Sha256: 34d1335a5d72fbacb1cf976c5c0d038fd88d6a3ad5fbe993e476e9b01ff3f637
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# This module optics module PhysicsPlus # This class optics formulas class Optics def self.absolute_refractive_index(speed) raise 'speed must not exceed the speed of light' if Constants::C < speed raise 'speed must be positive' if speed.negative? (Constants::C / speed.to_f) end def self.power_lens(focal_length) raise 'optical distance must be positive' if focal_length.negative? raise 'optical distance must not be zero' if focal_length.zero? 1/focal_length.to_f end def self.thin_lens_formula(f, d) raise 'distance from object to lens must be positive' if d.negative? raise 'distance from image to lens must be positive' if f.negative? raise 'distance from object to lens must not be zero' if d.zero? raise 'distance from image to lens must not be zero' if f.zero? (f + d)/(f.to_f * d) end def self.linear_magnification_lens(image_size, item_size) raise 'image size must be positive' if image_size.negative? raise 'item size must be positive' if item_size.negative? raise 'image_size not be zero' if image_size.zero? raise 'item_size not be zero' if item_size.zero? image_size.to_f/item_size end def self.interference_minimum_condition(k, lambda) (2*k+1)*lambda.to_f/2 end def self.interference_maximum_condition(k, lambda) k * lambda.to_f end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
physics_plus-0.0.7 | lib/physics_plus/optics.rb |
physics_plus-0.0.6 | lib/physics_plus/optics.rb |