Ray

class raytracing.Ray(y: float = 0, theta: float = 0, z: float = 0, isBlocked: bool = False, wavelength: float = None)

Bases: object

A vector and a light ray as transformed by ABCD matrices.

The Ray() has a height (y) and an angle with the optical axis (theta). It also has a position (z) initially at z=0, the diameter of the aperture at that point when it propagated through, and a marker if it has been blocked by the aperture.

Simple static functions are defined to obtain a group of rays: fans originate from the same height but sweep a range of angles; fan groups are fans originating from different heights.

Parameters:
  • y (float) – Initial height of the ray. (Default=0)

  • theta (float) – Initial angle of the ray. (Default=0)

z

Position of the ray along the optical axis. Initialized at 0.

Type:

float

apertureDiameter

The diameter of any blocking aperture at the present position z. Initialized at +Inf.

Type:

float

isBlocked

Whether or not the ray was blocked by an aperture. Initialized to False.

Type:

bool

See also

raytracing.rays

static along(rayTrace, z)

This function returns a ray at position z along the ray trace. y and theta are linearly interpolated in between the two closest rays.

Parameters:
  • rayTrace (list of Ray) – The rayTrace

  • z (float) – Position in z where we want the output ray

Returns:

ray – A Ray at position z, with y and theta interpolated from the ray trace

Return type:

an interpolated Ray

Notes

If the ray at an earlier z is blocked, then the Ray will be blocked too

at(z)

This function returns a ray at position z parallel to the current ray. Z is not the distance, it is the position. The distance is (z-self.z)

Parameters:

z (float) – Position in z where we want the output ray

Returns:

ray – A Ray at position z, with y interpolated and theta unchanged

Return type:

an interpolated Ray

Notes

If ray is blocked, then the output Ray will be blocked too

property isNotBlocked: bool

Opposite of isBlocked. Convenience function for readability.

Examples

>>> from raytracing import *
>>> # define an input ray
>>> ray1=Ray(y=1,theta=0.1)
>>> # define a lens to propagate the ray through
>>> mat=Matrix(A=1,B=0,C=-1/5,D=1,physicalLength=2,apertureDiameter=2,label='Lens')
>>> ray1Output=mat.mul_ray(ray1)
>>> print('the ray is not blocked? :', ray1Output.isNotBlocked)
the ray is not blocked? : True

Methods

__init__([y, theta, z, isBlocked, wavelength])

along(rayTrace, z)

This function returns a ray at position z along the ray trace.

at(z)

This function returns a ray at position z parallel to the current ray.

fan(*args, **kwargs)

fanGroup(*args, **kwargs)

Inherited Methods

Attributes

apertureDiameter

isBlocked

isNotBlocked

Opposite of isBlocked.

theta

wavelength

y

z