主要内容

distanceBefore

Query distance before optical component

Since R2026a

    Description

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

    dBefore = distanceBefore(opsys,cInd) returns the distance between the optical component at the specified index cInd of the optical system opsys and the previous component in the sequence, in global coordinates.

    example

    Examples

    collapse all

    Create an empty optical system.

    opsys = opticalSystem;

    To add a lens component to the optical system, create the two refractive surfaces of the lens using the addRefractiveSurface object function. Specify the lens glass material using the Material name-value argument for the first surface. Specify the center thickness of the lens, in millimeters, using the DistanceToNext name-value argument.

    addRefractiveSurface(opsys,Radius=50,DistanceToNext=1.5,Material=pickGlass("N-BK7")) 
    addRefractiveSurface(opsys,Radius=-50)

    Add a gap using the addGap object function.

    addGap(opsys,20)

    Add a diaphragm using the addDiaphragm object function. Specify the diaphragm properties using the DistanceToNext and SemiDiameter name-value arguments.

    addDiaphragm(opsys,DistanceToNext=28,SemiDiameter=2)

    Add an image plane using the addImagePlane object function.

    addImagePlane(opsys,SemiDiameter=2)

    Display a 2-D visualization of the optical system using the view2d object function.

    view2d(opsys,Labels="component")

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Optical System.

    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
    
    

    Query the distance between the second and third components in the optical system using the distanceBefore object function. Specify the index of the third component to query the distance between it and the previous component.

    dBefore = distanceBefore(opsys,3)
    dBefore = 
    28
    

    Modify the distance between the second and third components in the optical system using the changeGap object function.

    changeGap(opsys,3,7,GapLocation="before");

    Query the new distance between the first and second components in the optical system using the distanceBefore object function.

    dBefore = distanceBefore(opsys,2)
    dBefore = 
    20
    

    Display the optical system in 2-D using the view2d function.

    view2d(opsys,Labels="component")

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Optical System.

    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
    
    

    Input Arguments

    collapse all

    Optical system, specified as an opticalSystem object.

    Component index, specified as a positive scalar. The index indicates the position in the Components property of the opticalSystem object opsys before or after which the distance to the previous component is to be queried.

    Output Arguments

    collapse all

    Distance before the optical component, returned as a positive scalar. This value indicates the distance, in millimeters, between the specified optical component cInd and the previous component in the sequence, in global coordinates.

    Version History

    Introduced in R2026a