differt.rt module#
Ray Tracing utilities.
Image method
Image-based path tracing.
|
Return the ray paths between pairs of vertices, that reflect on a given list of mirrors in between. |
Return the image of vertices with respect to mirrors. |
|
Return the intersection points between rays and (infinite) planes. |
Fermat path tracing
Path tracing utilities that utilize Fermat’s principle.
Fermat’s principle states that the path taken by a ray between two given points is the path that can be traveled in the least time [21]. In a homogeneous medium, this means that the path of least time is also the path of least distance.
As a result, this module offers minimization methods for finding ray paths.
|
Return the ray paths between pairs of vertices, that reflect or diffract on a given list of objects in between. |
|
Return the ray paths between pairs of vertices, that reflect on a given list of mirrors in between. |
Path candidates iterators
Useful utilities to generate path candidates, see Generating path candidates.
To generate a subset of all paths between two vertices, e.g., a transmitter TX and a receiver RX, path tracing methods generate each ray path from a corresponding path candidate.
A path candidate is simply a list of primitive indices to indicate with what primitive the path interacts, and in what order. The latter indicates that any permutation of a given path candidate will result in another path.
I.e., the path candidate [4, 7] indicates that
the path first interacts with primitive 4, then
primitive 7, while the path candidate [7, 4]
indicates a path interacting first with 7 then
with 4.
An empty path candidate indicates a direct path from TX or RX, also known as line-of-sight path.
In general, interaction can be anything of the following: reflection, diffraction, refraction, etc. The utilities present in this module do not take care of the interaction type.
For fine tuning, use differt_core.rt’s graphs and iterators.
You can also read more about path candidates in [1].
|
Generate an array of all path candidates for fixed path order and a number of primitives. |
Iterator variant of |
|
Iterator variant of |
All returned iterators are of the following type.
- class SizedIterator(iter, size)[source]#
A custom generic class that is both
IteratorandSized.The main purpose of this class is to be able to use tqdm utilities on iterators and have some meaningful information about how iterations are left.
- Parameters:
Examples
The following example shows how to create a sized iterator.
>>> from differt.rt import SizedIterator >>> l = [1, 2, 3, 4, 5] >>> it = SizedIterator(iter=iter(l), size=5) >>> len(it) 5 >>> it = SizedIterator(iter=iter(l), size=l.__len__) >>> len(it) 5
Sanity checks
Utilities to check that ray paths are physically valid.
Check if consecutive vertices, but skipping one every other vertex, are on the same side of a given mirror. |
|
|
Return the first triangle hit by each ray. |
|
Return whether rays intersect any of the triangles using the Möller-Trumbore algorithm. |
|
Return whether rays intersect corresponding triangles using the Möller-Trumbore algorithm. |
|
Return whether triangles are visible from vertex positions. |