CompactRays
- class raytracing.compact.CompactRays(compactRaysStructuredBuffer=None, maxCount=None, rays=None)
Bases:
RaysA contiguous buffer holding many rays, ready for GPU transfer.
Where a regular
Raysis a Python list of independentRayobjects,CompactRaysstores all ray data in a single numpy structured array so that the memory can be sent to an OpenCL or CUDA device in one call.Individual rays are accessed with
compact_rays[i], which returns aCompactRayview — not a copy. Modifying the view modifies the buffer.Three construction modes are supported:
From an existing buffer (
compactRaysStructuredBuffer) — wraps raw bytes, typically received back from the GPU after computation.From a count (
maxCount) — allocates a zero-filled buffer of the requested size, to be filled later.From a list of ``Ray`` objects (
rays) — allocates a buffer and copies each ray into it, converting from Python objects to the compact layout.
- Parameters:
compactRaysStructuredBuffer (buffer, optional) – A pre-existing contiguous buffer of
CompactRay.Structdata.maxCount (int, optional) – Number of ray slots to allocate (zero-filled).
rays (list of Ray, optional) – Regular
Rayobjects to convert into the compact layout.
- Raises:
ValueError – If none of the three construction arguments is provided.
See also
CompactRayA view into one slot of this buffer.
- append(tuple)
A ray can be appended to the List of the rays using this function.
- Parameters:
ray (object of ray class) – a ray with height y and angle theta
- fillWithRandomUniform(yMax=1.0, yMin=None, thetaMax=1.5707963267948966, thetaMin=None)
Fill the buffer with rays at random heights and angles.
Each ray receives a uniformly distributed height in [yMin, yMax] and angle in [thetaMin, thetaMax]. If the minimum values are not given, symmetric ranges around zero are used.
- Parameters:
yMax (float) – Maximum height. (Default=1.0)
yMin (float, optional) – Minimum height. Defaults to
-yMax.thetaMax (float) – Maximum angle in radians. (Default=pi/2)
thetaMin (float, optional) – Minimum angle in radians. Defaults to
-thetaMax.
- property thetaValues
Returns the angles of rays in the list.
- property yValues
Returns the heights of rays in the list.
Methods
|
|
|
A ray can be appended to the List of the rays using this function. |
|
Fill the buffer with rays at random heights and angles. |
Inherited Methods
|
This function plots the intensity profiles of a list of rays. |
|
This function prints the progress of the iterations |
|
A list of rays can be loaded using this function. |
|
This functions calculates the histogram for the angle of the rays. |
|
This functions calculates the histogram for the height of the rays. |
|
A list of rays can be saved using this function. |
Attributes
|
Returns the number of rays in the list. |
|
|
Returns the angles of rays in the list. |
|
Returns the heights of rays in the list. |