5. Advanced Features of LensLab



5.1 Changing the Rendering Options

5.1.1 Using ShowRange
5.1.2 Using ColorView
5.1.3 Using OutputType
5.1.4 Using LineStyle and FillStyle
5.1.5 Other Rendering Options

5.2 Building Optical Systems in a Modular Fashion

5.3 Finding the Focus of a Lens System

5.4 User-Defined Models

5.4.1 Using ModelRefractiveIndex
5.4.2 Using ModelSurfaceShape
5.4.3 Using ModelRayColor
5.4.4 Using ModelIntensity

5.5 How to Specify Different Aperture Shapes

5.5.1 The Circular and Elliptical Apertures
5.5.2 The Rectangular Aperture
5.5.3 The Polygonal Aperture

5.6 The Refractive Index Options


This chapter introduces features of LensLab important to the advanced user. First, Section 5.1 discusses the different rendering options in LensLab. Then, Section 5.4 shows how components and ray sources can be used in modular units. Each modular unit can be moved in space and then chained together with other units to describe a complete system. In Section 5.5, we learn about LensLab's built-in functions for determining focal points in optical systems. Section 5.6 discusses LensLab's built-in modeling functions. Then, Section 5.7 discusses how to shape the edges of components. Finally, Section 5.8 explains the various refractive index options of LensLab.

Loading LensLab

Make sure that the LensLab package is located either in the home directory, or on a directory path recognized by Mathematica for packages. The LensLab package is named LensLab.m and located in the LensLab directory, and the LensLab package is loaded with the following expression.



LensLab version 1.3.2 is now loaded.

This loading process should only take a few seconds. In addition to being loaded as a package, the LensLab.m file is formatted as a Mathematica notebook. The LensLab source code is made accessible so that you can develop new functions of your own by studying LensLab's built-in functions. This is particularly helpful when you wish to model new component ideas in LensLab. However, you should receive permission from Optica Software before distributing any user-created functions that are derived from the LensLab source code. The unauthorized distribution of LensLab-derived code may be a LensLab license agreement violation or a copyright infringement.

Go to list of topics

5.1 Changing the Rendering Options

In this section, we discuss in more detail the various rendering options of DrawSystem and ShowSystem. Typically, you first perform a ray-tracing operation by evaluating DrawSystem. After this initial ray-tracing step, you can examine various parameter characteristics very quickly using ShowSystem. ShowSystem carries no options of its own, but uses most of the options listed for DrawSystem. We now examine some of these options.




RowBox[{{, RowBox[{PlotTypeFull3D, ,, RunningCommentaryFalse, ,, ThresholdInte ... n, , RowBox[{-, 0.5}]}], ,, YShadowPosition1, ,, ZShadowPosition -1}], }}]

In addition to the DrawSystem options, you can use any of the Graphics or Graphics3D options for rendering. In this way, you can include labels and titles with the rendered objects. For the rest of this section, we examine the rendering options uniquely associated with LensLab.

5.1.1 Using ShowRange

ShowRange is very useful for viewing segments of very large optical systems. By displaying a subset of components in the system, ShowRange can be used to "zoom-in" on a particular component area.

ShowRange->values uses ComponentNumber values to select the components and ray segments being displayed.

ShowRange can either take the value All or a list of the ComponentNumber values.


sys = DrawSystem[
    {LineOfRays[1, NumberOfRays->6],
    Move[PlanoConvexLens[100,50,10, CurvatureDirection->Back],{110,0,0}],


In the picture shown above, the first two elements are too small to be clearly seen. We next zoom-in on the first two elements using ShowRange.




ShowRange points to a list of one or more numbers. These numbers refer to the ComponentNumber of the elements to be displayed. Rays are displayed that contain the ComponentNumber parameters specified with ShowRange.

Go to list of topics

5.1.2 Using ColorView

ColorView is a powerful visualization tool that chooses the ray parameter to be represented by the ray color. Normally, each ray is colored to represent its wavelength. You can use ColorView to have ray colors associated with ray parameters in addition to wavelength. Here we define ColorView.

ColorView->rayparameterlabel is used to render rays with specified colors according to rayparameterlabel.

ColorView gives rayparameterlabel to ModelRayColor for determining ray colors. As  examples: you can use ColorView->Black to render the rays in black; ColorView->WaveLength attempts to match the color of the ray to the wavelength; ColorView->Automatic displays the initial RGBColor values assigned for the RayLineRGB ray parameter; ColorView->rayparameterlabel for any rayparameterlabel other than WaveLength attempts to colorize each ray segment according to the rank of the rayparameterlabel value within the possible range of rayparameterlabel values, for the displayed rays selected by RayChoice and ShowRange.

If more than one rayparameterlabel is indicated or the parameter gives a vector of three elements, then each of three values is assigned to the red, green, and blue colors. ColorView may also point to a list of three numbers representing the red, green, and blue colors used.

ColorView uses the ModelRayColor function for rendering rays in different formats. You can develop your own color mapping schemes with ModelRayColor. Section 5.5 discusses ModelRayColor in more detail.

Now we look at some examples using the ColorView option. First we use DrawSystem in the normal fashion.


ill = DrawSystem[{


By selecting PlotType->Surface and ColorView->OpticalLength, we monitor the variance in optical path length across the lens surface.




Similarly, we can color-render the variance in tilt angles for the rays plotted in either two or three dimensions.







We can change the rendering to a graylevel format using the option, ColorView->{RayLength,GrayLevel}.




Or we can make the rendered rays black using ColorView->Black.




You can use SetOptions[DrawSystem,ColorView->Black] to designate black-rendered rays as the default ColorView setting.

Go to list of topics

5.1.3 Using OutputType

It is sometimes desirable to create graphics in LensLab to be used in other Mathematica packages or displayed with non-LensLab produced images. These things can be done with OutputType.

OutputType specifies the final output form from ShowSystem and DrawSystem.

OutputType uses word values OpticalSystem and StandardGraphics. If StandardGraphics mode is indicated, then ShowSystem and DrawSystem return a graphics object in the standard Mathematica format. In the default OpticalSystem mode, ShowSystem and DrawSystem return component and ray information that can be analyzed and manipulated by LensLab. The following system will be used to demonstrate OutputType.


sys = DrawSystem[{
    WedgeOfRays[10, NumberOfRays->6],
    Boundary[{-100,-100,-100},{200,100,100}]}, PlotType->TopView]



OpticalSystem[{Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray}, {PlanoConvexLens, Boundary}, -OpticsGraphics-]

Here we see that OpticalSystem[listofrays, listofcomponents, -OpticsGraphics-] is returned from DrawSystem. This OpticalSystem object contains all information to completely describe the system of rays and components. Even though the image displays a flattened two-dimensional view of the objects, we can quickly see the full three-dimensional view using ShowSystem.





OpticalSystem[{Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray, Ray}, {PlanoConvexLens, Boundary}, -OpticsGraphics-]

Once again, OpticalSystem[listofrays, listofcomponents, -OpticsGraphics-] is the very last thing to be returned by ShowSystem. We now set OutputType->StandardGraphics in ShowSystem.


standardgraphics =




This time the -Graphics- label is returned by ShowSystem. We can now display this object with other graphic objects in Mathematica by using the standard Show function. As an example, we make a standard plot of the parabola function.


plot = Plot[.01 x^2 - 25,{x,0,100}]




Next, we use Show to merge the rendering of the parabola with the ray tracing of the lens.






You can also work with three-dimensional rendering in a similar fashion.

Go to list of topics

5.1.4 Using LineStyle and FillStyle

FillStyle and LineStyle are options of DrawSystem that give the component rendering styles.

FillStyle carries a list of graphics styles for rendering of filled surfaces.

LineStyle carries a list of graphics styles for rendering of edges and wire-framed surfaces.

You can modify the thickness and color in rendered component lines with LineStyle. The default option setting for LineStyle is
LineStyle->{GrayLevel[0.], AbsoluteThickness[0.5]}. This means that component edges are rendered in black with a 0.5-point line thickness.

FillStyle lets you change the color of shaded component surfaces. The default option setting for FillStyle is FillStyle->{GrayLevel[0.5]}. This means that shaded component surfaces are rendered in gray.

Go to list of topics

5.1.5 Other Rendering Options

In this section we examine the several options available for altering the graphical rendering of components and rays. The default rendering options of a Component object can be identified by examining Options[componentname]. As an example, we examine Options[PlanoConvexLens].




RowBox[{{, RowBox[{ComponentMediumBK7, ,, RowBox[{Temperature, , 20.}], ,, Tra ... eRendering {{Fill, Trace}}, EdgeRenderingFill, CrossRenderingEmpty}}], }}]

Listed above are several graphics-related options. These options are given in a hierarchy of levels. At the top of the hierarchy is the GraphicDesign option.

GraphicDesign is an option of all rendered components indicating the style of rendering.

The GraphicDesign option uses Automatic, Sketch, Wire, and Solid to denote different rendering styles for PlanoConvexLens. Automatic, Sketch, Wire, and Solid are themselves options of PlanoConvexLens, and can take a combination of the four word values defined below.

Empty indicates that no graphics will be created.

Fill denotes that the surface graphics should be filled with shaded areas.

Mesh designates that the surface graphics should be rendered with mesh outlines.

Trace specifies that surfaces are rendered with outlined borders and no shading.

Component rendering commands.

When specifying the graphical rendering of a component, it is possible to modify a particular GraphicDesign option in two different ways. The broadest method is to simply change the definition of a particular suboption using SetOptions.

The second method is to directly include a suboption in the component function's options at the time of rendering. As an example, we render PlanoConvexLens.




Next, we replace Mesh of the EdgeRendering with Fill.




In this way we can custom-render various objects. Similarly, you can change the rendering options of rays. Ray-rendering options include RayLineRGB, RayPointRGB, RayLineThickness, RayPointSize, RayLineStyle, and RayPointStyle. By including one or more of these options within a ray-source function, the rays from that source will be rendered accordingly. Ray-rendering options may also be inserted into DrawSystem and ShowSystem to change the rendering effects, even after the ray tracing is completed. See Section 9.4 for details about ray-rendering parameters.

Go to list of topics

5.2 Building Optical Systems in a Modular Fashion

One of the nicer aspects of LensLab is its ability to work with optical systems in a modular fashion. To illustrate this, we first model a beam-expanding spatial filter.


spatialfilter =


Note that Screen is used in place of Boundary. Because Screen doesn't absorb the ray's energy, it allows rays to continue propagating into components attached to the module.

Next, we feed the spatial filter into a larger lens.


collimator =
    Move[ PlanoConvexLens[100,50,10,
            CurvatureDirection->Back], {110,0,0}],


Finally, we introduce a second spatial filter to the collimation system. This time we use MoveDirected for positioning the spatial filter.


    collimator}, PlotType->TopView];


Notice the internal reflections occurring within the larger lens. Here we examine these internal lens reflections more closely with a simplified system.


    MoveDirected[ LineOfRays[1],{0,110},{110,23}, SideOfObject->After],
    Move[PlanoConvexLens[100,55,10, CurvatureDirection->Back],{110,0,0}],


A laboratory experiment using an HeNe laser pointed into a large planoconvex lens confirms the results generated here by LensLab. No stray transmitted light appears at the internal reflection points!

Go to list of topics

5.3 Finding the Focus of a Lens System

LensLab has two built-in functions for determining the focal point of any arbitrary imaging system, FindFocus and FindFocusFast. In this section, we compare the use of FindFocus and FindFocusFast for determining focal points.

FindFocus[objectset, selectionproperties, options] determines the minimum spot size for a locus of rays specified in selectionproperties.

FindFocusFast[objectset, selectionproperties, options] is a function similar to FindFocus that determines the minimum spot size for a locus of rays specified in selectionproperties.

FindFocusFast is useful for taking quick measurements of focal points in space. However, FindFocus gives a more accurate answer for the focal length at the cost of working more slowly. Because FindFocusFast uses a different algorithm from FindFocus, FindFocusFast can also measure virtual-image focal points.

Next, we use FindFocus to measure the focus of a simple planoconvex lens. To use FindFocus, we first use DrawSystem to trace some rays through the lens. To make the focal point measurement more challenging, we use off-axis rays.


offaxis = DrawSystem[{


Here is a view from the top.




Now we use FindFocus for measuring the off-axis focal point. We must specify a surface for FindFocus to begin its search. FindFocus will iteratively try moving a screen-like object to different positions along the chief ray until a minimum spot size is determined. In this example, we use a Boundary surface (ComponentNumber->2) as the starting surface. Although not used here, you can use the FindFocus option, ProgressReport->True, to monitor the progress toward a convergent solution. As FindFocus gets close to a solution, the reported number value changes by only small amounts from its last value. Note that FindFocus is one of the most time-consuming functions in LensLab. Also note that the number of optical elements in the system is irrelevent to the processing time. Only the number of rays affects the process time. Since FindFocus uses the built-in function, FindRoot, you can shorten the calculation time by changing the AccuracyGoal option of FindRoot. This may diminish the solution's accuracy, however. To compare the speed difference between FindFocus and FindFocusFast, we use Timing.





RowBox[{{, RowBox[{RowBox[{3.31,  , Second}], ,, RowBox[{{, RowBox[{RowBox[{FocalPoint, ᢃ ... [{FocalPlaneTilt, , RowBox[{{, RowBox[{0.993411, ,, 0.114608, ,, 0.}], }}]}]}], }}]}], }}]

Notice that FindFocus prints a spot diagram of the focal plane along with the focal point information. Here we see that the focal point is at {194, 15.9, 0} in three-dimensional space. On the NeXT computer, this took 112 seconds to execute. The focal spot size is .63 mm, and the focal distance to the closest lens surface is 84 mm. For FindFocus, FocalLength is defined as the length of the chief ray running between the last optical surface and the focal point. Finally, the focal plane is tilted in space at {.99,.11,0}.

Used as an alternative to FindFocus, FindFocusFast gives an approximate focal point result. FindFocusFast does not give information about SpotSize and FocalLength, however. Now we use FindFocusFast to measure the same system.




RowBox[{{, RowBox[{RowBox[{0.12,  , Second}], ,, RowBox[{{, RowBox[{RowBox[{FocalPoint, ᢃ ... [{FocalPlaneTilt, , RowBox[{{, RowBox[{0.993411, ,, 0.114608, ,, 0.}], }}]}]}], }}]}], }}]

Here we can see that the focal point is {195.0, 15.9, 0}, which is a slightly different from the result given by FindFocus. However, this result required less time to execute, making the routine more useful if a large number of field points are to be determined. FindFocusFast has the added advantage in that it is capable of measuring the focal points of virtual images that don't converge in front of the lens system. Next, we trace rays through a negative lens.


virtual = DrawSystem[{


Here is the view from the top.




Finally, we use FindFocusFast to measure the virtual focal point.




RowBox[{{, RowBox[{RowBox[{FocalPoint, , RowBox[{{, RowBox[{RowBox[{-, 66.5654}], ,, R ...  RowBox[{FocalPlaneTilt, , RowBox[{{, RowBox[{0.976704, ,, 0.214591, ,, 0.}], }}]}]}], }}]

We see that the focal point is located behind the lens and has negative values.

Go to list of topics

5.4 User-Defined Models

LensLab contains four model functions that affect the behavior of the ray-tracing and rendering operations. These models are used to define the characteristics of various optical materials, surface contours, and rendering of rays, and they are designed to be easily expanded by the user for creating new models. The model functions are ModelIntensity, ModelRayColor, ModelRefractiveIndex, and ModelSurfaceShape.

First, we demonstrate ModelRefractiveIndex and ModelSurfaceShape. Then we present definitions for ModelIntensity and ModelRayColor.

Go to list of topics

5.4.1 Using ModelRefractiveIndex

We use ModelRefractiveIndex to define new refractive materials in LensLab. Here is the definition of ModelRefractiveIndex.

ModelRefractiveIndex[materialname] is a ray-parameter- dependent function that models the refractive properties of materials identified by materialname. Such properties depend on parameters such as WaveLength and Temperature.

You can use CreateRefractiveIndexModel to create new refractive index models.  Here is the definition of CreateRefractiveIndexModel.

CreateRefractiveIndexModel[datalist, materiallabel] creates a wavelength-dependent model that is fitted to the data according to the standard refractive-index power series formula, used by IndexFunction.

In this example, we create a refractive index for olive oil. We begin by determining the refractive index of olive oil at several different wavelengths. In this case, these values are given by Table 6e-1 in the American Institute of Physics Handbook. We copy these values into CreateRefractiveIndexModel, using OliveOil in materiallabel.




ModelRefractiveIndex[OliveOil] =IndexFunction[0.7874298075670467, 1.7558040961293055, 0.21299228426244415, 0.032664636101866734, 0.0004161914550870577, -0.0016283590925955803];

Unfortunately, only three measurements were given in this table for olive oil. In order for CreateRefractiveIndexModel to correctly function, we must have at least five measurement values. If no other data about olive oil are available, we can either work with a simpler interpolation function and abandon the use of CreateRefractiveIndexModel, or we can find two additional data points by inspecting the graph above with the cursor and visually interpolate. In order to sample the graph for data point values, we first select the graph by pointing the cursor to it and clicking once on the mouse button. Next, hold the Command key with the cursor circling over the graph. The cursor will now take the form of a crosshatch. By centering the crosshatch about a particular point and then clicking once on the mouse button, a dot appears at that spot that indicates that the point was sampled. After making two or three sample points, press Command-C to store the sampled point values in a buffer (for notebook front ends). These numbers are pasted below by clicking below this cell and pressing Command-V.


{{0.537657, 1.478918}, {0.623571, 1.475123}};

We evaluate CreateRefractiveIndexModel again by first pasting the values into the first argument slot.


    {{0.537657, 1.478918}, {0.623571, 1.475123},
    {.486,1.4825},{.589,1.4763},{.656,1.4738}}, OliveOil]


ModelRefractiveIndex[OliveOil] =IndexFunction[2.849164607733883, -0.7453135708866219, -0.11003496272340632, -0.06715161769852113, 0.027130830762186905, -0.002691330720744096];

Since the generated graph looks valid, we next copy the contents of the last cell produced by CreateRefractiveIndexModel and paste either into the "Material Models" section of the LensLab package, or someplace else. Since ModelRefractiveIndex is protected outside of the LensLab package, we create a model function outside the LensLab package using Unprotect and Protect.




ModelRefractiveIndex[OliveOil] = IndexFunction[1.037865726506557, 0.3255935172589225, 1.10257198606559, -0.4685721975519883, 0.0928006855233136, -0.006936011433425642];



Now we use OliveOil with ComponentMedium and IntrinsicMedium to create components having the refractive index of olive oil.


    {WedgeOfRays[10, NumberOfRays->6],


Go to list of topics

5.4.2 Using ModelSurfaceShape

In a similar fashion to ModelRefractiveIndex, ModelSurfaceShape can be used to define surface shapes for custom optical elements. This is an alternative to using one of the built-in, custom Component object functions such as CustomLens or CustomMirror that allows three-dimensional functions to be directly entered as arguments to the object.

ModelSurfaceShape[surfacelabel, value] is a global function that is used by ComponentFoundation to create surface functions defining the component surfaces.

ModelSurfaceShape gives a surface function expression to SurfaceFunction in Component. Users can add new surface definitions by assigning new functions to ModelSurfaceShape with surfacelabel that names the surface type. The value parameter can be a single number or list of numbers, and it specifies surface curvature characteristics. ModelSurfaceShape can either define a three-dimensional surface using a function of two parameters or a list of three parametric functions. New definitions may be assigned to ModelSurfaceShape by evaluating either ModelSurfaceShape[surfacelabel, value] = {SurfaceFunction->{Function[fx[s, t]], Function[fy[s, t]], Function[fz[s, t]]}} for explicitly parametric surface functions or ModelSurfaceShape[surfacelabel, value] = {SurfaceFunction->Function[fx[s, t]]} for simple surface functions. Before the user can define new ModelSurfaceShape functions, the ModelSurfaceShape must first be unprotected or included within the "Model Functions" section of the LensLab package.

As an example, we define an elliptical surface for ModelSurfaceShape. First we need to determine the general mathematical form for the ellipsoid surface. We start with the three-dimensional ellipse function (x/a)^2 + (y/b)^2 + (z/c)^2= r^2 and solve for z. We store our ellipse solutions in the temporary variable, ellipse3D.



ellipse3D[a_,b_,c_,r_,x_,y_] =
    Solve[(x/a)^2 + (y/b)^2 + (z/c)^2 == r^2,z]


{{z -c (r^2 - x^2/a^2 - y^2/b^2)^(1/2)}, {zc (r^2 - x^2/a^2 - y^2/b^2)^(1/2)}}

Notice that we have two solutions, one positive valued and the other negative valued. In addition, the solutions are given with replacement rules, z->solution. Before we work with these results, we use [[2]] to extract the positive solution, and use ReplaceFor (/.) to remove the replacement rule dependent of the result. These changes are inserted back into ellipse3D.


ellipse3D[a_,b_,c_,r_,x_,y_] =


c (r^2 - x^2/a^2 - y^2/b^2)^(1/2)

Before using the equation to define an optical surface, we need to determine appropriate values for the constants a, b, c, and r by testing different constant values with Plot3D.




Finally, we create a new ModelSurfaceShape definition using ellipticalshape for the surfacelabel parameter of ModelSurfaceShape. Here we use lower case letters to distinguish ellipticalshape from a potential built-in EllipticalShape label.




ModelSurfaceShape[ellipticalshape,{a_,b_,c_,r_}] =
        Function[{s,t},c*(r^2 - s^2/a^2 - t^2/b^2)^(1/2)]};



Note that we could have instead used three explicit parametric functions to define the surface.

ModelSurfaceShape[ellipticalshape,{a_,b_,c_,r_}] =
        {Function[{s,t},c*(r^2 - s^2/a^2 - t^2/b^2)^(1/2)],

Now we create a component using this new surface model. For this, we use SurfaceLabel->ellipticalshape.





{{EllipticalMirror}, -OpticsGraphics-}

Alternatively, we can create a specific object for a single purpose by using the surface function directly.


    10.*(20.^2 - s^2/10.^2 - t^2/10.^2)^(1/2)],



{{EllipticalMirror}, -OpticsGraphics-}

For more examples of modeling functions, see the "Model Functions" section in the LensLab package.

Go to list of topics

5.4.3 Using ModelRayColor

ModelRayColor determines the way rays get rendered including their colors. Here we define ModelRayColor.

ModelRayColor[rayparameterlabels, {minvalue, maxvalue}] = Function[ parametervalue ] attempts to convert the ray parameters indicated by rayparameterlabels into rendered color values.

Custom ray-rendering schemes can be defined for various ray-parameter labels by using ModelRayColor[rayparameterlabel, {min_, max_}] = Function[{parametervalue}, function[parametervalue]], where function[parametervalue] returns graphics styles such as Hue, GreyLevel, and RGBColor.  

ModelRayColor uses the rayparameterlabel from the ColorView option of DrawSystem. Arguments minvalue and maxvalue are calculated based on the minimum and maximum parameter values from the currently displayed rays, selected by the RayChoice option. As a default for undefined ray parameter labels given by the ColorView option, ModelRayColor assigns a color Hue to each ray according to the segment parameter's numerical position between minvalue and maxvalue, with red being assigned to the maximum encountered parameter value. Parameters composed of three elements are evaluated by independently representing each element with a red, green, or blue value. Two-element parameters are assigned a red and a green value, each representing an element. DrawSystem option ColorView->WaveLength attempts to match the wavelength of the ray to the perceived visual color of that wavelength. Option ColorView->Black may be used to produce black-rendered ray lines. Before the user can define new ModelRayColor functions, ModelRayColor must be unprotected or included within the "ModelRayColor" section of the LensLab package.

Before developing new ModelRayColor functions, see the "Model Functions" section of the LensLab package for previously assigned definitions.

Go to list of topics

5.4.4 Using ModelIntensity

ModelIntensity changes the light intensity of rays for different optical media, and provides the user with an opportunity to model gain and absorption. Here we define ModelIntensity.

ModelIntensity[materialname] is a function evaluated by the ray-tracing engine at every ray/surface interface and is used for modeling the bulk absorptive properties of materials identified by materialname.

ModelIntensity may depend on various parameters including Intensity, WaveLength, OpticalLength, RefractiveIndex, and Temperature, and returns a single intensity value that is stored in the Intensity parameter of the ray. User-specified intensity model libraries of refractive materials can be created by listing and evaluating ModelIntensity[materialname] = intensityfunction for different specified materialnames as shown by the example below.


ModelIntensity["test"] = Function[(Intensity*Exp[-(RayLength/10)^2])/.#];
test"] = ModelRefractiveIndex[BK7];


ReadRays[DrawSystem[{Ray[], Move[Screen[50],50],Move[Window[50,10,ComponentMedium->"test"],50],Boundary[100]},PlotType->TopView],Intensity,All]



RowBox[{{, RowBox[{100., ,, 100., ,, 36.7879, ,, 36.7879}], }}]

The default intensityfunction for unspecified materialnames leaves Intensity unchanged. ModelIntensity may be based on spectroscopic data, and can be used to model gain (in lasers) as well as absorption. Before the user can define new ModelIntensity functions, they must be unprotected or included in the "Materials" section of the LensLab package.

Go to list of topics

5.5 How to Specify Different Aperture Shapes

The edges of most lenses, mirrors, and baffles can be specified as either circular, rectangular, elliptical, or polygonal, depending on the type and number of elements used in the aperture parameter of the component function. In this section, we examine how these various types of edge shapes are specified.

5.5.1 The Circular and Elliptical Apertures

You can specify a circular aperture by using a single number in the aperture parameter of the component function. Here we denote a circular shape for a cylindrical lens.




You can indicate an elliptical shape instead by denoting the major and minor ellipse dimensions with two negative numbers in the aperture parameter. Here is an example using an elliptical shape for the outer dimensions of PinHole with a circular hole.




Similarly, you can list two negative numbers to designate an elliptical hole. Here we use an elliptical hole in ParabolicMirrorWithHole. We also use the HoleOffset option to position the hole away from the surface center.


        HoleOffset->{15,20}], Boxed->False];


Not shown, you can also specify polygon-edged holes by listing the corner coordinates of the polygon.

Go to list of topics

5.5.2 The Rectangular Aperture

You can specify a rectangular shape by indicating the major and minor dimensions with a list of two positive numbers. Here we use a rectangular aperture with SphericalMirror.


DrawSystem[SphericalMirror[500,{100,50},30], Boxed->False];


Go to list of topics

5.5.3 The Polygonal Aperture

You can specify a polygon-edged component by using a list of coordinates denoting the corners of the polygon. Here we create a triangular-edged lens.


DrawSystem[    PlanoConvexLens[100,{{-25,-25},{0,25},


You can also use Table to create a polygon-edged component. Here we create a hexagon-shaped mirror.


    Table[50*N[{Sin[x Degree],Cos[x Degree]}],


Go to list of topics

5.6 The Refractive Index Options

LensLab has four options that relate information about the refractive index. These are ComponentMedium, IntrinsicMedium, OpticalMedium, and RefractiveIndex. In this section, we examine how these options are used. Here we define the four options.

ComponentMedium is an option of component functions that indicates the type of material used in the fabrication of the component.

IntrinsicMedium is a rule of Ray giving a label that identifies the background optical medium surrounding components.

OpticalMedium is a rule of Ray that identifies the optical material medium being traversed by each ray segment.

RefractiveIndex is a rule of Ray that signifies the refractive index value for the ray segment in the local environment and uses ModelRefractiveIndex to calculate its value.

Definitions of refractive index related options.

ComponentMedium is an option of component functions, and IntrinsicMedium is an option of ray-source functions. During the ray-tracing process, both ComponentMedium and IntrinsicMedium alternately specify a label used with ModelRefractiveIndex to calculate a value for the RefractiveIndex option. Presently, there are 32 such labels built into LensLab, where each label identifies a particular material. Here is a listing of these built-in material labels.

Acetone              PAN               SF5
Air                  PMMA              Silicon
BaK1                 PS                SK11
BK7                  PVA               Suprasil
CrownGlass           PVB               Toluene
Ethanol              PVF               Turpentine
Ether                PVP               Ultran30
FusedSilica          Pyrex             Vacuum
Glycerine            Quartz            Water
LaSF9                Sapphire          ZincSelenide
Methanol             SF11

Names of built-in optical materials.

In addition to ModelRefractiveIndex, these labels are used by other material-related models, such as ModelIntensity. Section 5.4 shows you how to define new materials in LensLab by using ModelRefractiveIndex and ModelIntensity.

OpticalMedium identifies the local ray environment by carrying an appropriate material label. Depending on whether a particular ray segment is located within a component, or outside a component, the OpticalMedium rule of Ray gets its value from either ComponentMedium or IntrinsicMedium. When the ray first enters a component, the ComponentMedium label from the particular component is used in OpticalMedium. Then, when the ray leaves the component, the IntrinsicMedium label is once again used in OpticalMedium. Both OpticalMedium and RefractiveIndex are rules generated during the ray tracing and are indirectly specified by ComponentMedium and IntrinsicMedium. Generally, the ray carries the same IntrinsicMedium value throughout the ray-tracing process. In some cases, however, some components (such as  IntrinsicSurface) may alter the ray's IntrinsicMedium parameter to indicate a change in the refractive environment for other optical components.

Go to list of topics

Copyright Statement

LensLab is a trademark of Optica Software.
Mathematica ® is a registered trademark of Wolfram Research, Inc. All other product names mentioned are trademarks of their producers. Mathematica is not associated with Mathematica Policy Research, Inc. or MathTech, Inc.
Copyright ©1995-2005 by Optica Software, Urbana, Illinois, Champaign, Illinois.

All rights reserved. No part of this document may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior written permission of the author, Optica Software.

Optica Software is the holder of the copyright to the LensLab package software and documentation ("Product") described in this document, including without limitation such aspects of the Product as its code, structure, sequence, organization, "look and feel", programming language and compilation of command names. Use of the Product, unless pursuant to the terms of a license granted by Optica Software. or as otherwise authorized by law, is an infringement of the copyright.

Optica Software makes no representations, express or implied, with respect to this Product, including without limitations, any implied warranties of merchantability or fitness for a particular purpose, all of which are expressly disclaimed. Users should be aware that included in the terms and conditions under which Optica Software is willing to license the Product is a provision that the author, Optica Software and distribution licensees, distributors and dealers shall in no event be liable for any indirect, incidental or consequential damages, and that liability for direct damages shall be limited to the amount of the purchase price paid for the Product.

In addition to the foregoing, users should recognize that all complex software systems and their documentation contain errors and omissions. Optica Software shall not be responsible under any circumstances for providing information on or corrections to errors and omissions discovered at any time in this document or the package software it describes, whether or not they are aware of the errors or omissions. Optica Software does not recommend the use of the software described in this document for applications in which errors or omissions could threaten life, injury or significant loss.

Go to list of topics

Created by Mathematica  (November 2, 2005)