samplingGrid
Description
Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.
A samplingGrid object creates a sampling grid in the
xy-plane of the local surface coordinate frame, that defines the initial
positions and angles of rays entering the optical system through the entrance pupil or first
surface.
You can specify the sampling grid as a fixed shape, such as a uniformly sampled square or
hexapolar pattern, or as a random grid of points. You can also specify a custom sampling grid
using x- and y-coordinates. The coordinates you specify
must be normalized to the range [–1, 1], where the coordinate [0 0] defines
the center of the entrance surface.
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.
Creation
Syntax
Description
Specify Sampling Grid Shape
creates a sampling grid
with 11 evenly spaced coordinate points along the y-axis at
x = 0.sg = samplingGrid
creates a
square sampling grid with 11 coordinate points per side.sg = samplingGrid("Square")
creates a square sampling grid with sg = samplingGrid("Square",numPointsPerSide)numPointsPerSide points per
side.
creates a
hexapolar sampling grid with 8 concentric rings of coordinate points.sg = samplingGrid("Hexapolar")
creates a
randomly spaced sampling grid containing 100 points.sg = samplingGrid("Random")
creates a
stratified sampling grid with 11 points per side. This grid type contains an even
distribution of points across the sampling area but introduces random variation within
each grid cell.sg = samplingGrid("Stratified")
creates a stratified sampling grid with sg = samplingGrid("Stratified",numPointsPerSide)numPointsPerSide points per
side.
Specify Custom Grid Coordinates
Input Arguments
Output Arguments
Properties
Examples
Tips
When you specify a stratified sampling grid, the algorithm uses a random number generator to introduce randomness. To obtain reproducible results, set the random seed before generating the grid. To set the random seed, use the
rngfunction before generating the stratified sampling grid.
Algorithms
Version History
Introduced in R2026a



