Skip to content

Light rays propagation in 2D, in the geometrical optics approximation

License

Notifications You must be signed in to change notification settings

ederag/geoptics

Repository files navigation

GeOptics

image

GeOptics propagates light rays in 2D, in the Geometrical optics approximation.

Modifying objects should be easy, with a live update of the rays propagation. The intent being to give a fun experience with optics.

That being said, physical precision is kept, so GeOptics might interest engineers or physicists looking for a quick way to test ideas.

Features

GeOptics is currently in alpha stage, which means that not only the internals but also the API and file formats are going to change a lot, probably losing backward compatibility.

Nevertheless, it seems quite usable, with the following features:

  • Regions are defined by their enclosing surface and their refractive index.
  • Non-sequential propagation: intersections between the ray and the dioptres are determined at run-time.
  • After each interface crossing, ray direction is determined by Snell-Descartes laws.
  • Total internal reflection is handled gracefully.
  • Sources and regions can be moved by mouse. Rays propagation is live updated.
  • Regions may overlap. The topmost regions determines the refractive index of the intersection.
  • Scenes and individual sources and regions can be saved or loaded.
  • Graphical user interface (currently Qt, but other toolkits could be added)
  • Command line (IPython) creation, inspection and control of the scene.

Future

  • Region edition by mouse.
  • Multiple undo/redo mechanism.
  • Ideal thin lenses.
  • Plugin mechanism for new types of regions or sources.
  • Inspection and edition of sources or regions properties directly in the GUI.
  • Live measurement of distances between nodes. (for instance between source and first intersection of a ray with the optical axis)
  • Wavelengths for rays, and materials for regions (currently, a single refractive index is used)
  • Physical color (additive synthesis) for rays superposition, if so desired. This seems to work in pyoptics.
  • Demonstrations (rainbow, ...)
  • (Serious) games:
    • puzzles: how to place sources or lenses to strike a target ?
    • shoot-them-up
    • build-a-base
    • ...
  • List far from complete...

Installation

Requirements

The main gui toolkit is Qt, but there is a good separation between GUI and non GUI stuff. In principle, this could allow for other toolkits as well. If there is enough interest, a limited tkinter gui could be revived, for display purposes.

From repo

$ git clone https://github.com/ederag/GeOptics.git
$ cd GeOptics/

Usage

Run the t_geo.py script

$ python3 t_geo.py

or, to start with an empty scene,

$ python3 -m geoptics

In the menu, select file>Open>screenshot.geoptics; the window should now resemble the above screenshot.

For an interactive command line control, there is an interface with IPython.

Documentation

Documentation can be found online on geoptics.readthedocs.io, or built locally by going into the docs/ directory and issuing make html.

Contributing

Contribution are welcome. Although beware that the code is in alpha stage, with deep modifications ahead.

For instance, currently the points passed as arguments are automatically copied. This completely avoided side effects. But for handling regions modifications, sharing a point between curves would make things easier. And more pythonic.

Help with these essential internals would be appreciated. It should be advisable to discuss before any extensive work though. There are some indications about the current design choices in the documentation.

Otherwise, for the time being, please keep changes small, preferably only small bug fixes.

Forks

Forks are welcome, and upon progress could be mentioned here, with a description of the main changes or goals. This would reduce the "fork maze effect" that can be so puzzling.

History

This project started years ago, inspired by a long discontinued shareware program called raytrace.exe. Meanwhile, a lot of other python projects emerged, including

The list is far from complete. Please file an issue to ask for additions.

Had these projects been known earlier, this one would never have started. And it snowballed, too big to stop... Let it be useful, or perhaps swallowed into another free software project. This would be nice.

License

GeOptics is free software, distributed under the terms of the "GPL3 or later" license.

About

Light rays propagation in 2D, in the geometrical optics approximation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published