Class: PhysicsPlus::Optics
- Inherits:
-
Object
- Object
- PhysicsPlus::Optics
- Defined in:
- lib/physics_plus/optics.rb
Overview
This class optics formulas
Class Method Summary collapse
- .absolute_refractive_index(speed) ⇒ Object
- .interference_maximum_condition(k, lambda) ⇒ Object
- .interference_minimum_condition(k, lambda) ⇒ Object
- .linear_magnification_lens(image_size, item_size) ⇒ Object
- .power_lens(focal_length) ⇒ Object
- .thin_lens_formula(f, d) ⇒ Object
Class Method Details
.absolute_refractive_index(speed) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/physics_plus/optics.rb', line 5 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 |
.interference_maximum_condition(k, lambda) ⇒ Object
44 45 46 |
# File 'lib/physics_plus/optics.rb', line 44 def self.interference_maximum_condition(k, lambda) k * lambda.to_f end |
.interference_minimum_condition(k, lambda) ⇒ Object
40 41 42 |
# File 'lib/physics_plus/optics.rb', line 40 def self.interference_minimum_condition(k, lambda) (2*k+1)*lambda.to_f/2 end |
.linear_magnification_lens(image_size, item_size) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/physics_plus/optics.rb', line 30 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 |
.power_lens(focal_length) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/physics_plus/optics.rb', line 12 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 |
.thin_lens_formula(f, d) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/physics_plus/optics.rb', line 20 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 |