Skip to content

Commit

Permalink
Added some text to the docs on the zernike distortions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryancole committed Mar 1, 2021
1 parent 04c8e9e commit 3207652
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
35 changes: 34 additions & 1 deletion doc/source/distortions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,37 @@ turns out to be useful at the C-level during tracing. I.e.::
dZdY = grad[...,1]
Z = grad[...,2]

Zernike Polymonial Distortions
------------------------------

More general distortions can be applied using the :py:class:`raypier.distortions.ZernikeSeries` class.

As previously, instances of this object are passed to a :py:class:`raypier.faces.DistortionFace` , along
with the base-surface to which the distortion is to be applied.

.. py:class:: ZernikeSeries(unit_radius=10.0, coefficients=[])
:canonical: raypier.distortions.ZernikeSeries

Describes a general distortion defined in terms of Zernike polynomials.
The ANSI single-index (J) notation is used to identify coefficients.

A recursive algorithm is used for evaluation of the function with caching
for efficient evaluation where many non-zero coefficients exist.

Both the given parameters are traits on this object and updates to either
one will automatically update the internal state of the object (and trigger
re-tracing of the model).

:param float unit_radius: Specifies the unit-radius for the Zernike polynomials.
:param list coefficients: A sequence of coefficient amplitudes, given a tuples (J, amplitude).
E.g. [(0,0.1),(2,0.3),(7,2.34)]. Any number of coefficients
can be specified.


An example of the this class in action can be seen here:

.. literalinclude:: /../../examples/zernike_distortion_example.py

.. image:: images/zernike_distortion_example.png


7 changes: 4 additions & 3 deletions examples/zernike_distortion_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@


shape = CircleShape(radius=10.0)

#f1 = SphericalFace(z_height=0.0, curvature=-25.0)

f1 = PlanarFace(z_height=0.0)
f2 = PlanarFace(z_height=5.0)

#dist = SimpleTestZernikeJ7(unit_radius=10.0, amplitude=0.01)
#dist = NullDistortion()

dist = ZernikeSeries(unit_radius=10.0, coefficients=[(i,0.0) for i in range(12)])
f1 = DistortionFace(base_face=f1, distortion=dist)


class Sliders(Constraint):
"""Make a Constrain object just to give us a more convenient UI for adjusting Zernike coefficients.
"""
J0 = Range(-1.0,1.0,0.0)
J1 = Range(-1.0,1.0,0.0)
J2 = Range(-1.0,1.0,0.0)
Expand Down

0 comments on commit 3207652

Please sign in to comment.