主要内容

removeRays

Remove traced rays from visualization of optical system

Since R2026a

    Description

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

    removeRays(osv) removes all traced rays from the optical system visualization osv.

    example

    removeRays(osv,rayIndex) removes only the rays in the ray bundles with the specified indices rayIndex from the optical system visualization osv.

    Examples

    collapse all

    Create a simple optical system.

    opsys = opticalSystem;
    addRefractiveSurface(opsys,Radius=9,Material=[1.74 25.4],DistanceToNext=3)
    addRefractiveSurface(opsys,Radius=-9,DistanceToNext=10)
    addImagePlane(opsys)
    focus(opsys);

    Visualize the optical system in 2-D.

    osv2d = view2d(opsys,Title="Convex Lens")

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Convex Lens.

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

    Trace rays in the optical system to add to the visualization. Observe that rays contains three ray bundles.

    rays = traceRays(opsys)
    rays=1×3 RayBundle array with properties:
        FieldPoint
        Wavelength
        Sampling
        RayData
    
    

    Add the rays to the visualization. Each ray bundle is represented by a different color in the visualization.

    addRays(osv2d,rays)

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Convex Lens.

    Remove the third ray bundle in the visualization.

    removeRays(osv2d,3)

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Convex Lens.

    Add component labels to the visualization. The lens and image plane components are labeled as C1 and C2 in the visualization.

    osv2d.Labels = "component";

    Figure contains an object of type optics.ui.opticalsystemviewer2d. The chart of type optics.ui.opticalsystemviewer2d has title Convex Lens.

    Create a simple optical system.

    opsys = opticalSystem;
    addRefractiveSurface(opsys,Radius=9,Material=[1.74 25.4],DistanceToNext=3) 
    addRefractiveSurface(opsys,Radius=-9,DistanceToNext=10)
    addImagePlane(opsys)

    Visualize the optical system in 3-D.

    osv3d = view3d(opsys,Title="Convex Lens")

    osv3d = 
      OpticalSystemViewer3D with properties:
    
                  Title: [0×0 string]
                 Labels: "none"
              ClipAngle: 0
                   Rays: [0×0 optics.ui.Rays3D]
        BackgroundColor: [0.9608 0.9608 0.9608]
          GradientColor: [0.9020 0.9020 0.9020]
                 Parent: [1×1 Figure]
    
      Show all properties
    
    

    Trace rays in the optical system to add to the visualization. Observe that rays contains three ray bundles.

    rays = traceRays(opsys)
    rays=1×3 RayBundle array with properties:
        1×1 RayBundle    1×1 RayBundle    1×1 RayBundle
    
    

    You can add only one ray bundle to a 3-D visualization. Add one of the ray bundles from the traced rays to the visualization.

    addRays(osv3d,rays(1))

    Explode the visualization. The explosion moves each component in the optical system visualization radially outward to enable you to better visualize the internal structure of the optical system.

    explode(osv3d)

    Restore the visualization to its state before the explosion.

    unexplode(osv3d)

    Show only the lens element, which is the first optical component, in the visualization.

    showComponents(osv3d,1)

    Remove the rays from the visualization.

    removeRays(osv3d)

    Add component labels to the visualization.

    osv3d.Labels = "component";

    Input Arguments

    collapse all

    Optical system visualization to customize, specified as an OpticalSystemViewer2D or OpticalSystemViewer3D object.

    Indices of ray bundles to remove, specified as a numeric vector. Removing a ray bundle removes all rays in that bundle from the visualization.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Version History

    Introduced in R2026a