From 3207652a5f863fe06b1c3b33a2f218db5977685d Mon Sep 17 00:00:00 2001 From: bryancole Date: Mon, 1 Mar 2021 16:55:56 +0000 Subject: [PATCH] Added some text to the docs on the zernike distortions. --- doc/source/distortions.rst | 35 +++++++++++++++++++++++++- examples/zernike_distortion_example.py | 7 +++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/doc/source/distortions.rst b/doc/source/distortions.rst index 2c0ec41..3e12b29 100644 --- a/doc/source/distortions.rst +++ b/doc/source/distortions.rst @@ -49,4 +49,37 @@ turns out to be useful at the C-level during tracing. I.e.:: dZdY = grad[...,1] Z = grad[...,2] - \ No newline at end of file +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 + + diff --git a/examples/zernike_distortion_example.py b/examples/zernike_distortion_example.py index 7a28ca3..7963361 100644 --- a/examples/zernike_distortion_example.py +++ b/examples/zernike_distortion_example.py @@ -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)