optiland.rays.real_rays#

Real Rays

This module contains the RealRays class, which represents a collection of real rays in 3D space.

Kramer Harrison, 2024

Classes

RealRays(x, y, z, L, M, N, intensity, wavelength)

Represents a collection of real rays in 3D space.

class RealRays(x: ArrayLike, y: ArrayLike, z: ArrayLike, L: ArrayLike, M: ArrayLike, N: ArrayLike, intensity: ArrayLike, wavelength: ArrayLike)[source]#

Represents a collection of real rays in 3D space.

This class stores ray positions, directions, and properties as arrays, supporting both NumPy and PyTorch backends for efficient computation.

Variables:
  • x – x-coordinates of ray positions.

  • y – y-coordinates of ray positions.

  • z – z-coordinates of ray positions.

  • L – x-components of ray direction cosines.

  • M – y-components of ray direction cosines.

  • N – z-components of ray direction cosines.

  • i – Intensity values of the rays.

  • w – Wavelength values of the rays.

  • opd – Optical path difference values.

  • L0 – Pre-surface x-direction cosines (None until surface interaction).

  • M0 – Pre-surface y-direction cosines (None until surface interaction).

  • N0 – Pre-surface z-direction cosines (None until surface interaction).

Note

Direction cosines should be normalized: L² + M² + N² = 1.

clip(condition: BEArray)[source]#

Clip the rays based on a condition.

gratingdiffract(nx: float, ny: float, nz: float, fx: float, fy: float, fz: float, m: int, d: float, n1: float, n2: float, is_reflective: bool)[source]#

Diffract the rays on a surface with a grating.

Parameters:
  • nx – The x-component of the surface normal.

  • ny – The y-component of the surface normal.

  • nz – The z-component of the surface normal.

  • fx – The x-component of the grating vector.

  • fy – The y-component of the grating vector.

  • fz – The z-component of the grating vector.

  • d – The grating spacing

  • m – The grating diffraction order

  • n1 – IOR of the pre surface material

  • n2 – IOR of the post surface material

  • is_reflective – Wether the surface is reflective or not

normalize()[source]#

Normalize the direction vectors of the rays.

record_on_surface(surface: Surface) None[source]#

Dispatch to the surface’s real ray record method.

Parameters:

surface (Surface) – The surface to record onto.

reflect(nx: float, ny: float, nz: float)[source]#

Reflects the rays on the surface.

Parameters:
  • nx – The x-component of the surface normal.

  • ny – The y-component of the surface normal.

  • nz – The z-component of the surface normal.

refract(nx: float, ny: float, nz: float, n1: float, n2: float)[source]#

Refract rays on the surface.

Parameters:
  • nx – The x-component of the surface normals.

  • ny – The y-component of the surface normals.

  • nz – The z-component of the surface normals.

rotate_x(rx: ScalarOrArray)[source]#

Rotate the rays about the x-axis.

Parameters:

rx – Rotation angle around x-axis in radians.

rotate_y(ry: ScalarOrArray)[source]#

Rotate the rays about the y-axis.

Parameters:

ry – Rotation angle around y-axis in radians.

rotate_z(rz: ScalarOrArray)[source]#

Rotate the rays about the z-axis.

Parameters:

rz – Rotation angle around z-axis in radians.

trace_on_surface(surface: Surface) RealRays[source]#

Dispatch to the surface’s real ray trace kernel.

Parameters:

surface (Surface) – The surface to trace through.

Returns:

The traced real rays.

Return type:

RealRays

translate(dx: ArrayLike, dy: ArrayLike, dz: ArrayLike)#

Shifts the rays in the x, y, and z directions.

Parameters:
  • dx – The amount to shift the rays in the x direction.

  • dy – The amount to shift the rays in the y direction.

  • dz – The amount to shift the rays in the z direction.

update(jones_matrix: BEArray | None = None)[source]#

Update ray properties (primarily used for polarization).