traceChiefRay
R2026bDescription
Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.
specifies options for tracing a chief ray using one or more name-value arguments. For
example, chiefRay = traceChiefRay(opsys,Name=Value)FieldPoints=fieldPoint(Position=[1 0 1]) specifies to trace
the chief ray from a light source at the position (1,0,1) in the global
reference frame.
Examples
Load a wide angle lens from a ZMX file into the workspace.
opsys = zmximport("WideAngleLens.zmx");Define a field angle representation of a light source at infinity, with a field angle of 20 degrees from the z-axis, using the fieldPoint function.
fp = fieldPoint(Angles=[20 0]);
Trace a chief ray through the optical system using the traceChiefRay object function.
cr = traceChiefRay(opsys,FieldPoints=fp,Wavelengths=587);
Define a hexapolar sampling grid of coordinate points, through which to sample traced rays, using the samplingGrid function.
sg = samplingGrid("Hexapolar",6);Trace rays through the optical system using the traceRays object function. Specify the defined hexapolar sampling grid using the SamplingGrid name-value argument.
rb = traceRays(opsys,FieldPoints=fp,Wavelength=587,SamplingGrid=sg);
Display the optical system using the view2d object function, and visualize the traced rays through the system using the addRays object function. The chief and sample rays are visualized in blue and red, respectively.
hv = view2d(opsys); addRays(hv,rb,Color="r") addRays(hv,cr,Color="b")

Input Arguments
Optical system for which to trace a chief ray, specified as an opticalSystem object.
By default, the traceChiefRay function traces the chief ray from
the field points specified by the FieldPoints property of the opticalSystem
object, at the operational wavelengths specified by the Wavelengths property of the opticalSystem
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: traceChiefRay(FieldPoints=fieldPoint(Position=[1 0 1]))
specifies to trace the chief ray from a light source at the position
(1,0,1) in the global reference frame.
Field point representation of a light source, specified as one of these options:
FieldPoints value | Light Source Type |
|---|---|
Array of | Field points represent light sources that are at an infinite distance from the first surface of the optical system. |
Array of | Field points represent light sources that are at a finite distance from the first surface of the optical system. |
Array of FieldPosition and FieldAngle
objects | Field points represent two types of light sources, either at an infinite distance and at a finite distance from the first surface of the optical system. |
By default, the value of FieldPoints is set by the
FieldPoints property of the optical system
opsys.
Additional ray properties to compute, specified as one or more of these values.
The traceChiefRay function returns the specified ray properties
as additional fields in the RayData property of the RayBundle
object in chiefRay. Each value of
RayProperties, except "All", creates a field
of the same name in RayData.
RayProperties Value | Field Value in RayData |
|---|---|
| Fresnel reflection and transmission coefficients at each interface, bulk transmission and phase shift, and the total transmittance through the optical system, represented as a structure with these fields.
|
| Polarization transformation matrices for each ray and surface intersection, represented as a structure with these fields.
|
| Adds all additional ray properties to
|
For more information about the global and local coordinate systems, see Coordinate Systems in Optics.
Wavelengths for which to trace rays, specified as an M-element numeric vector. M is the number of wavelengths. Each element of the vector is a wavelength, in nanometers, specified as a positive scalar.
Output Arguments
Chief ray traced through the optical system, returned as an
N-by-M matrix of RayBundle
objects. N is the number of field points, and M is
the number of wavelengths for which the chief ray is traced. Each element of the matrix
is a RayBundle object that represents the chief ray originating from
the corresponding field point.
The chief ray is a ray that originates from the field point and passes through the center of the entrance pupil halfway between the upper and lower marginal rays of the optical system. The intersection of the chief ray with the image plane determines the image position for a particular field point.
Note
The traceChiefRay function attempts to trace rays for each
specified field point at the entrance pupil. If rays cannot be traced for a particular
field point, the function skips tracing for that field point and continues tracing
rays for the remaining field points.
Limitations
The traceChiefRay function determines the chief ray by locating the
entrance pupil using marginal ray tracing. For optical systems with surface discontinuities or
non-convex apertures, the entrance pupil and corresponding chief ray can be ill-defined. In
these cases, traceChiefRay might be unable to identify a unique chief ray
for a specific field point and wavelength combination.
To visualize the actual ray paths through such systems, use traceRays and
specify an explicit sampling surface using the SamplingSurface argument,
such as "first-surface".
Version History
Introduced in R2026aUsing the traceChiefRay function, you can now compute Fresnel terms and
polarization matrices by specifying the RayProperties name-value
argument.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)