主要内容

insert

Insert optical component into optical system

Since R2026a

    Description

    Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.

    insert(opsys,component) inserts an optical component into the optical system halway between origin and the first optical system component.

    insert(opsys,component,InsertBefore = nextIdx) specifies to insert the component before an existing optical system component with the index nextIdx using a name-value argument. For example, InsertBefore=1 specifies to insert the component at an equal distance between the origin and first component in the optical system.

    insert(opsys,component,InsertAfter = priorIdx) specifies to insert the component after an existing optical system component with the index priorIdx using a name-value argument. For example, InsertAfter=1 specifies to insert the component at an equal distance between the first and second components in the optical system.

    example

    Note

    This functionality requires the Optical Design and Simulation Library for Image Processing Toolbox™. You can install the Optical Design and Simulation Library for Image Processing Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    Examples

    collapse all

    Create an optical system that contains a double Gauss lens using the createDoubleGauss helper function. The function is attached to this example as a supporting file. Display a 2-D visualization of the optical system using the view2d object function.

    opsys = createDoubleGauss;            
    view2d(opsys,Labels="component")

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title 55-mm F/1.2 for 35-mm SLR.

    ans = 
      OpticalSystemViewer2D with properties:
    
                Title: ""
        OpticalSystem: [1×1 opticalSystem]
               Labels: "component"
          FieldPoints: "on"
                 Rays: [0×0 optics.ui.Rays2D]
               Parent: [1×1 Figure]
    
      Show all properties
    
    

    Remove the second optical component from the optical system using the remove function. The removed component is the first doublet.

    remove(opsys,2)

    Create a new lens component, meniscus, using the LensElement object. Specify the glass lens material using the Materials property, and specify the center thickness of meniscus, in millimeters, using the Thickness property.

    meniscus = optics.component.LensElement(SemiDiameter=20,Thickness=2,Materials=[1.64 58]);
    meniscus.Surfaces(1).Radius = 56;
    meniscus.Surfaces(2).Radius = 40;

    Insert the lens into the optical system, after the first component, using insert object function.

    insert(opsys,meniscus,InsertAfter=1)

    Adjust the gap between first element and the inserted lens using the changeGap function.

    changeGap(opsys,1,5,GapLocation="after");

    Display a 2-D visualization of the modified optical system using the view2d object function, and trace marginal rays through the optical system using the traceMarginalRays object function.

    hv = view2d(opsys,Labels="component");
    mr = traceMarginalRays(opsys);

    Visualize the rays traced through the modified optical system using the addRays object function.

    addRays(hv,mr)

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title 55-mm F/1.2 for 35-mm SLR.

    Input Arguments

    collapse all

    Optical system, specified as an opticalSystem object.

    Optical system component, specified as a Component object.

    Prior component index, specified as a positive scalar. This value indicates the index of the component, in the Components property of the opticalSystem object opsys, after which to insert the component specified by component. The order of the components in the Components array is with respect to the ray propagation along the optical axis, beginning with the light source.

    Note

    If you specify the InsertAfter argument, you cannot specify the InsertBefore argument.

    Subsequent component index, specified as a positive scalar. This value indicates the index of the component, in the Components property of the opticalSystem object opsys, before which to insert the component specified by component. The order of the components in the Components array is with respect to the ray propagation along the optical axis, beginning with the light source.

    Note

    If you specify the InsertBefore argument, you cannot specify the InsertAfter argument.

    Alternative Functionality

    To add an optical component to the end of an optical system, use the add object function. Using this function, you can position this component either relative to the construction frame of the last component in the optical system, or relative to the global coordinate system.

    Version History

    Introduced in R2026a