CompactRay

class raytracing.compact.CompactRay(raysSource, index)

Bases: Ray

A view into a shared buffer that behaves like a Ray.

A regular Ray stores its data in normal Python attributes. A CompactRay instead reads and writes directly into a position inside a CompactRays buffer. From the outside it feels identical — you can still write ray.y = 1.0 or print(ray.theta) — but under the hood every access goes through the contiguous numpy array.

The memory layout of a single ray is defined by CompactRay.Struct, a numpy structured dtype with fields: y, theta, z, isBlocked, apertureDiameter, and wavelength (all 32-bit).

Parameters:
  • raysSource (CompactRays) – The owning buffer that holds the actual data.

  • index (int) – Position of this ray inside the buffer (0-based).

See also

CompactRays

The contiguous buffer that owns the data.

Ray

The base class whose interface is preserved.

assign(ray)

Copy all fields from a regular Ray into this buffer position.

This is the bridge between the object-oriented world (a Ray with Python attributes) and the GPU-friendly world (a slot in a contiguous numpy buffer).

Parameters:

ray (Ray) – The source ray whose fields will be copied.

Methods

__init__(raysSource, index)

Create a view for one ray inside the shared buffer.

assign(ray)

Copy all fields from a regular Ray into this buffer position.

Inherited Methods

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)

Attributes

Struct

apertureDiameter

elementAsStruct

isBlocked

isNotBlocked

Opposite of isBlocked.

theta

wavelength

y

z