rayoptics.elem.profiles module

Module for different surface profile shapes

resize_list(lst, new_length, null_item=None)[source]
intersect_parabola(cv, p, d, z_dir=1.0)[source]

Intersect a parabolid, starting from an arbitrary point.

Parameters:
  • cv – vertex curvature

  • p – start point of the ray in the profile’s coordinate system

  • d – direction cosine of the ray in the profile’s coordinate system

  • z_dir – +1 if propagation positive direction, -1 if otherwise

class SurfaceProfile[source]

Bases: object

Base class for surface profiles.

update()[source]
f(p)[source]

Returns the value of the profile surface function at point p.

df(p)[source]

Returns the gradient of the profile surface function at point p.

normal(p)[source]

Returns the unit normal of the profile at point p.

sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

profile(sd, dir=1, steps=6)[source]

Return a 2d polyline approximating the surface profile.

Parameters:
  • sd – semi-diameter of the profile

  • dir – +1 for profile from neg to postive direction, -1 if otherwise

  • steps – number of points to generate

apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

intersect(p0, d, eps, z_dir)[source]

Intersect a profile, starting from an arbitrary point.

Parameters:
  • p0 – start point of the ray in the profile’s coordinate system

  • d – direction cosine of the ray in the profile’s coordinate system

  • z_dir – +1 if propagation positive direction, -1 if otherwise

  • eps – numeric tolerance for convergence of any iterative procedure

Returns:

distance to intersection point s1, intersection point p

Return type:

tuple

Raises:

TraceMissedSurfaceError

intersect_welford(p, d, eps, z_dir)[source]

Intersect a profile, starting from an arbitrary point.

From Welford, Aberrations of Optical Systems (ISBN-10: 0852745648), eqs 4.34 thru 4.41.

Parameters:
  • p0 – start point of the ray in the profile’s coordinate system

  • d – direction cosine of the ray in the profile’s coordinate system

  • z_dir – +1 if propagation positive direction, -1 if otherwise

  • eps – numeric tolerance for convergence of any iterative procedure

Returns:

distance to intersection point s1, intersection point p

Return type:

tuple

Raises:

TraceMissedSurfaceError

intersect_spencer(p0, d, eps, z_dir)[source]

Intersect a profile, starting from an arbitrary point.

From Spencer and Murty, General Ray-Tracing Procedure

Parameters:
  • p0 – start point of the ray in the profile’s coordinate system

  • d – direction cosine of the ray in the profile’s coordinate system

  • z_dir – +1 if propagation positive direction, -1 if otherwise

  • eps – numeric tolerance for convergence of any iterative procedure

Returns:

distance to intersection point s1, intersection point p

Return type:

tuple

Raises:

TraceMissedSurfaceError

intersect_scipy(p0, d, eps, z_dir)[source]

Intersect a profile, starting from an arbitrary point.

Parameters:
  • p0 – start point of the ray in the profile’s coordinate system

  • d – direction cosine of the ray in the profile’s coordinate system

  • z_dir – +1 if propagation positive direction, -1 if otherwise

  • eps – numeric tolerance for convergence of any iterative procedure

Returns:

distance to intersection point s1, intersection point p

Return type:

tuple

Raises:

TraceMissedSurfaceError

class Spherical(c=0.0, r=None)[source]

Bases: SurfaceProfile

Spherical surface profile parameterized by curvature.

__init__(c=0.0, r=None)[source]

initialize a Spherical profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

property r
listobj_str()[source]
copyFrom(other)[source]
copyDataFrom(other)[source]
mutate(new_profile)[source]
apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

flip()[source]
intersect_tangent_plane(p, d, eps, z_dir)[source]
intersect(p, d, eps, z_dir)[source]

Intersection with a sphere, starting from an arbitrary point.

f(p)[source]

surface function for Spherical profile

This function implements Spencer’s eq 25, with kappa=1 (i.e. spherical).

To see this, start with the code: F = p[2] - 0.5*cv*(np.dot(p, p))

Expand np.dot(p, p): F = p[2] - 0.5*cv*(p[0]*p[0] + p[1]*p[1] + p[2]*p[2])

in Spencer’s notation: rho**2 = p[0]*p[0] + p[1]*p[1] Z = p[2]

Substituting notation, the result is: F = Z - 0.5*cv*(rho**2 + Z**2)

which is Spencer’s eq 25.

df(p)[source]

Returns the gradient of the profile surface function at point p.

sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

profile(sd, dir=1, steps=6)[source]

Generate a profile curve for the segment sd.

class Conic(c=0.0, cc=0.0, r=None, ec=None)[source]

Bases: SurfaceProfile

Conic surface profile parameterized by curvature and conic constant.

Conics produced for conic constant values:

  • cc > 0.0: oblate spheroid

  • cc = 0.0: sphere

  • cc < 0.0 and > -1.0: ellipsoid

  • cc = -1.0: paraboloid

  • cc < -1.0: hyperboloid

__init__(c=0.0, cc=0.0, r=None, ec=None)[source]

initialize a Conic profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

  • cc – conic constant

  • ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).

property r
property ec
listobj_str()[source]
copyFrom(other)[source]
copyDataFrom(other)[source]
apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

flip()[source]
intersect_tangent_plane(p, d, eps, z_dir)[source]
intersect(p, d, eps, z_dir)[source]

Intersection with a conic, starting from an arbitrary point.

f(p)[source]

surface function for Conic profile

This function implements Spencer’s eq 25, with kappa = ec = 1 + cc

df(p)[source]

Returns the gradient of the profile surface function at point p.

sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

profile(sd, dir=1, steps=6)[source]

Return a 2d polyline approximating the surface profile.

Parameters:
  • sd – semi-diameter of the profile

  • dir – +1 for profile from neg to postive direction, -1 if otherwise

  • steps – number of points to generate

append_pt_to_2d_profile(surface_profile, y, poly_profile)[source]

calc surface sag at y and append to poly if ok, else return None

aspheric_profile(surface_profile, sd, dir=1, steps=21)[source]
class EvenPolynomial(c=0.0, cc=0.0, r=None, ec=None, coefs=None)[source]

Bases: SurfaceProfile

Even Polynomial asphere up to 20th order, on base conic.

__init__(c=0.0, cc=0.0, r=None, ec=None, coefs=None)[source]

initialize a EvenPolynomial profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

  • cc – conic constant

  • ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).

  • coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.

property r
property ec
listobj_str()[source]
copyFrom(other)[source]
copyDataFrom(other)[source]
gen_coef_list()[source]
apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

flip()[source]
update()[source]
sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

f(p)[source]

Returns the value of the profile surface function at point p.

df(p)[source]

Returns the gradient of the profile surface function at point p.

profile(sd, dir=1, steps=21)[source]

Return a 2d polyline approximating the surface profile.

Parameters:
  • sd – semi-diameter of the profile

  • dir – +1 for profile from neg to postive direction, -1 if otherwise

  • steps – number of points to generate

class RadialPolynomial(c=0.0, cc=None, r=None, ec=1.0, coefs=None)[source]

Bases: SurfaceProfile

Radial Polynomial asphere, on base conic.

Conics produced for conic asphere values:

ec > 1.0: oblate spheroid ec = 1.0: sphere ec > 0.0 and < 1.0: ellipsoid ec = 0.0: paraboloid ec < 0.0: hyperboloid

initial_size = 10
__init__(c=0.0, cc=None, r=None, ec=1.0, coefs=None)[source]

initialize a RadialPolynomial profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

  • ec – conic asphere.

  • cc – conic constant (= ec - 1). If cc is specified, it overrides any input for the conic asphere (ec).

  • coefs – a list of radial coefficents, starting with the constant term, (and not exceeding the 10th order term).

property r
property cc
get_coef(exp)[source]
set_coef(exp, value)[source]
listobj_str()[source]
copyFrom(other)[source]
copyDataFrom(other)[source]
gen_coef_list()[source]
apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

flip()[source]
update()[source]
sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

f(p)[source]

Returns the value of the profile surface function at point p.

df(p)[source]

Returns the gradient of the profile surface function at point p.

profile(sd, dir=1, steps=21)[source]

Return a 2d polyline approximating the surface profile.

Parameters:
  • sd – semi-diameter of the profile

  • dir – +1 for profile from neg to postive direction, -1 if otherwise

  • steps – number of points to generate

class YToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]

Bases: SurfaceProfile

Y Aspheric toroid, up to 20th order, on base conic.

__init__(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]

initialize a EvenPolynomial profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

  • cR – toric sweep radius of curvature

  • rR – toric sweep radius

  • cc – conic constant

  • ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).

  • coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.

property r
property rR
property ec
listobj_str()[source]
copyFrom(other)[source]
copyDataFrom(other)[source]
gen_coef_list()[source]
apply_scale_factor(scale_factor)[source]

Apply scale_factor to the profile definition.

flip()[source]
update()[source]
sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

fY(y)[source]
f(p)[source]

Returns the value of the profile surface function at point p.

df(p)[source]

Returns the gradient of the profile surface function at point p.

profile(sd, dir=1, steps=21)[source]

Return a 2d polyline approximating the surface profile.

Parameters:
  • sd – semi-diameter of the profile

  • dir – +1 for profile from neg to postive direction, -1 if otherwise

  • steps – number of points to generate

class XToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]

Bases: YToroid

X Aspheric toroid, up to 20th order, on base conic. Leverage YToroid

__init__(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)[source]

initialize a EvenPolynomial profile.

Parameters:
  • c – curvature

  • r – radius of curvature. If zero, taken as planar. If r is specified, it overrides any input for c (curvature).

  • cR – toric sweep radius of curvature

  • rR – toric sweep radius

  • cc – conic constant

  • ec – conic asphere (= cc + 1). If ec is specified, it overrides any input for the conic constant (cc).

  • coefs – a list of even power coefficents, starting with the quadratic term, and not exceeding the 20th order term.

sag(x, y)[source]

Returns the sagitta (z coordinate) of the surface at x, y.

f(p)[source]

Returns the value of the profile surface function at point p.

df(p)[source]

Returns the gradient of the profile surface function at point p.

mutate_profile(old_profile, new_profile_type)[source]
test()[source]