Matrix.trace
- raytracing.Matrix.trace(self, ray)
The ray matrix formalism, through multiplication of a ray by a matrix, will give the correct ray but will never consider apertures. By “tracing” a ray, we explicitly consider all apertures in the system. If a ray is blocked, its property isBlocked will be true, and isNotBlocked will be false.
Because we want to manage blockage by apertures, we need to perform a two-step process for elements that have a finite, non-null length: where is the ray blocked exactly? It can be blocked at the entrance, at the exit, or anywhere in between. The aperture diameter for a finite-length element is constant across the length of the element. We therefore check before entering the element and after having propagated through the element. For now, this will suffice.
- Parameters:
ray (object of Ray class) – A ray at height y and angle theta
- Returns:
rayTrace – A list of rays (i.e. a ray trace) for the input ray through the matrix.
- Return type:
List of ray(s)
Examples
>>> from raytracing import * >>> # M is an ABCD matrix of a lens (f=10) >>> M= Matrix(A=1,B=0,C=-1/10,D=1,physicalLength=0,label='Lens') >>> # R1 is a ray >>> R1=Ray(y=5,theta=20) >>> Tr=M.trace(R1) >>> print('the height of traced ray is' , Tr[0].y, 'and the angle is', Tr[0].theta) the height of traced ray is 5.0 and the angle is 19.5
Notes
Currently, the output of the function is returned as a list. It is sufficient to trace (i.e. display) the ray to draw lines between the points. For some elements, (zero physical length), there will be a single element. For other elements there may be more. For groups of elements, there can be any number of rays in the list.
If you only care about the final ray that has propagated through, use traceThrough()