cihologramas / pyoptools

Python tools for optical design
GNU General Public License v3.0
136 stars 45 forks source link

NURBS raytracing #77

Open Jonas231 opened 4 years ago

Jonas231 commented 4 years ago

Hi guys, this package is very impressing.

Do you plan to implement NURBS raytracing? This would be very useful for this non-sequential optical raytracer for stray light analysis applications. I would very much like to contribute in this direction. One could start somewhere from here: https://github.com/orbingol/NURBS-Python Load the .iges-surfaces into python: e.g. https://github.com/Rod-Persky/pyIGES

Then perform raytracing: [Martin] Practical Ray Tracing of Trimmed NURBS Surfaces

Is it possible to track the traversed raypaths of any ray in pyoptools. Let's say ray A started at surface A, hit surface B at coordinate (x,y,z) with direction cosines ... and stoped at surface C... ?

ramezquitao commented 4 years ago

Hi,

This is something we can be easily done as long as we get the following information:

1- The equation of the nurbs z=f(x,y) 2- The intersection point of the nurb and an arbitrary ray 3- The normal of the nurb surface at the intersection point.

If you could help us with that, I can implement the nurbs surface in pyoptools fast.

About your second question, yes it is possible to track a ray in the propagation. I will prepare an example and send it to you.

Jonas231 commented 4 years ago

Sounds good. I will try.

  1. I should get with https://github.com/pyvista/pyiges. I have already plotted an aspheric mirror as a vtk mesh with it. A slight modification gives accesss to parameters of the iges.
  2. / 3. --> This seems to be the hard part and will take some time. When and if it is finished however I think your package will be very powerful. Have you considered using pyvista, vtk, mayavi (the like) for plotting the optical surfaces and rays?
Jonas231 commented 4 years ago

This master thesis conveys the complexity of the issue: "Ray Tracing NURBS Surfaces using CUDA" https://repository.tudelft.nl/islandora/object/uuid:7e04a67d-fc3c-4d11-a1e0-67043044e637/datastream/OBJ/download

ramezquitao commented 4 years ago

I added an example on how to follow the rays in the documentation at my branch. This has not been merged with the official branch yet, but you can see i the example here:

https://pyoptools-rao.readthedocs.io/en/latest/notebooks/basic/raypath_follow.html

Regarding using pyvista, vtk, mayavi: At the beginning of the development we used VTK, but it made the installation very complicated. After that we made a viewer using WX, but also to keep it working was a lot of work. Right now, the idea is that pyOpTools should work with the minimum amount of dependencies. For the moment, only the jupyter frontend is intended to be part of the main pyOpTools installation. Other kinds of front-ends, such as the Freecad workbech , are intended to be developed by separate.