Project

optical

0.0
No commit activity in last 3 years
No release in over 3 years
The home of all ruby optics
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6
>= 0
 Project Readme

Optical

Remember that optics class you took in college? Me neither, and that's why I wrote this gem.

Installation

Add this line to your application's Gemfile:

gem 'optical'

And then execute:

$ bundle

Or install it yourself as:

$ gem install optical

Usage

Lenses

The optical gem has primitives for modeling generic thin-lenses, as well as more specific lens types.

To model a simple thin lens, simply...

lens = Optical::Lens.new diameter:12.mm, focal_length:20.mm

A Plano-Convex lens is just as easy to make...

lens = Optical::Lens.new diameter:12.mm, focal_length:20.mm

Optical Systems

A simple optical system (no splitters) can be modeled using the familiar push syntax.

system = Optical::System.new
system.push Optical::Lens.new
system.push Optical::Lens.new

The two lenses in that last example won't have any space between, which is almost never what you want. You can set the distance between them by pushing a special spacer element.

system.push Optical::Lens.new
system.push Optical::System.spacer(10.mm)
system.push Optical::Lens.new

or you can simply push any Numeric-like object

system.push Optical::Lens.new
system.push 10.mm
system.push Optical::Lens.new

If you have a number of elements that all need the same spacing, you can set a default spacing value before pushing the elements. The default value will be in effect until changed.

system.spacing = 10.mm
system.push Optical::Lens.new	# These two elements will get a 10mm spacer
system.push Optical::Lens.new	#  added between them automatically