differt 0.0.23__tar.gz → 0.0.25__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {differt-0.0.23 → differt-0.0.25}/.gitignore +1 -1
- {differt-0.0.23 → differt-0.0.25}/PKG-INFO +35 -86
- {differt-0.0.23 → differt-0.0.25}/pyproject.toml +2 -2
- {differt-0.0.23 → differt-0.0.25}/src/differt/__init__.py +1 -1
- differt-0.0.25/src/differt/em/__init__.py +18 -0
- differt-0.0.23/src/differt/em/constants.py → differt-0.0.25/src/differt/em/_constants.py +0 -2
- differt-0.0.23/src/differt/em/special.py → differt-0.0.25/src/differt/em/_special.py +5 -5
- differt-0.0.23/src/differt/em/utd.py → differt-0.0.25/src/differt/em/_utd.py +2 -2
- differt-0.0.23/src/differt/em/utils.py → differt-0.0.25/src/differt/em/_utils.py +6 -6
- differt-0.0.25/src/differt/geometry/__init__.py +34 -0
- differt-0.0.23/src/differt/geometry/paths.py → differt-0.0.25/src/differt/geometry/_paths.py +2 -2
- differt-0.0.23/src/differt/geometry/triangle_mesh.py → differt-0.0.25/src/differt/geometry/_triangle_mesh.py +7 -9
- differt-0.0.23/src/differt/geometry/utils.py → differt-0.0.25/src/differt/geometry/_utils.py +9 -9
- {differt-0.0.23 → differt-0.0.25}/src/differt/plotting/_core.py +3 -3
- differt-0.0.25/src/differt/rt/__init__.py +33 -0
- differt-0.0.23/src/differt/rt/fermat.py → differt-0.0.25/src/differt/rt/_fermat.py +3 -12
- differt-0.0.23/src/differt/rt/image_method.py → differt-0.0.25/src/differt/rt/_image_method.py +85 -88
- differt-0.0.23/src/differt/rt/utils.py → differt-0.0.25/src/differt/rt/_utils.py +15 -15
- differt-0.0.25/src/differt/scene/__init__.py +11 -0
- differt-0.0.23/src/differt/scene/sionna.py → differt-0.0.25/src/differt/scene/_sionna.py +1 -11
- differt-0.0.23/src/differt/scene/triangle_scene.py → differt-0.0.25/src/differt/scene/_triangle_scene.py +21 -22
- differt-0.0.23/src/differt/em/__init__.py +0 -1
- differt-0.0.23/src/differt/geometry/__init__.py +0 -5
- differt-0.0.23/src/differt/rt/__init__.py +0 -1
- differt-0.0.23/src/differt/scene/__init__.py +0 -3
- {differt-0.0.23 → differt-0.0.25}/LICENSE.md +0 -0
- {differt-0.0.23 → differt-0.0.25}/README.md +0 -0
- /differt-0.0.23/src/differt/version.py → /differt-0.0.25/src/differt/_version.py +0 -0
- {differt-0.0.23 → differt-0.0.25}/src/differt/plotting/__init__.py +0 -0
- {differt-0.0.23 → differt-0.0.25}/src/differt/plotting/_utils.py +0 -0
- {differt-0.0.23 → differt-0.0.25}/src/differt/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: DiffeRT
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.25
|
|
4
4
|
Summary: Differentiable Ray Tracing Toolbox for Radio Propagation Simulations
|
|
5
5
|
Project-URL: Changelog, https://github.com/jeertmans/DiffeRT/releases
|
|
6
6
|
Project-URL: Documentation, https://eertmans.be/DiffeRT
|
|
@@ -21,7 +21,7 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
22
|
Requires-Dist: beartype>=0.17.2
|
|
23
23
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.0.
|
|
24
|
+
Requires-Dist: differt-core==0.0.25
|
|
25
25
|
Requires-Dist: equinox>=0.11.5
|
|
26
26
|
Requires-Dist: filelock>=3.15.4
|
|
27
27
|
Requires-Dist: jax>=0.4.32
|
|
@@ -74,9 +74,11 @@ Description-Content-Type: text/markdown
|
|
|
74
74
|
## Usage
|
|
75
75
|
|
|
76
76
|
> **WARNING:**
|
|
77
|
-
> Until this package reaches version `
|
|
78
|
-
> should be expected.
|
|
79
|
-
>
|
|
77
|
+
> Until this package reaches version `v0.1.0`, breaking changes
|
|
78
|
+
> should be expected.
|
|
79
|
+
> Checkout the [v0.1.0](https://github.com/jeertmans/DiffeRT/milestone/1)
|
|
80
|
+
> and [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestones for future
|
|
81
|
+
> features.
|
|
80
82
|
>
|
|
81
83
|
> If you have any suggestion regarding the development of this package,
|
|
82
84
|
> please open an [issue](https://github.com/jeertmans/DiffeRT/issues).
|
|
@@ -88,97 +90,44 @@ pip install differt
|
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
We provide pre-built binaries for most platforms. If you want (or need)
|
|
91
|
-
to build the package from the source distribution,
|
|
92
|
-
|
|
93
|
+
to build the package from the source distribution,
|
|
94
|
+
or want to customize the installation (e.g., with GPU support), check out the
|
|
95
|
+
[installation guide](https://differt.readthedocs.io/latest/installation.html).
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
> **IMPORTANT:**
|
|
97
|
-
> The current documentation is very light and a more complete guide for
|
|
98
|
-
> new contributors will be written in the near future.
|
|
99
|
-
>
|
|
100
|
-
> Until then, do not hesitate to reach me for help with
|
|
101
|
-
> [GitHub issues](https://github.com/jeertmans/DiffeRT/issues)!
|
|
102
|
-
|
|
103
|
-
This project is built using both Python and Rust code, to provide an easy-to-use
|
|
104
|
-
but performant program. It also heavily uses the capabilities brought by
|
|
105
|
-
[JAX](https://github.com/google/jax) for numerical arrays.
|
|
106
|
-
|
|
107
|
-
### Requirements
|
|
97
|
+
### Reporting an issue
|
|
108
98
|
|
|
109
|
-
|
|
99
|
+
<!-- start reporting-an-issue -->
|
|
110
100
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- [Maturin](https://www.maturin.rs/) for building Python bindings from Rust code;
|
|
116
|
-
- and [uv](https://docs.astral.sh/uv/) to manage this project.
|
|
101
|
+
If you think you found a bug,
|
|
102
|
+
an error in the documentation,
|
|
103
|
+
or wish there was some feature that is currently missing,
|
|
104
|
+
we would love to hear from you!
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
The best way to reach us is via the
|
|
107
|
+
[GitHub issues](https://github.com/jeertmans/DiffeRT/issues?q=is%3Aissue).
|
|
108
|
+
If your problem is not covered by an already existing (closed or open) issue,
|
|
109
|
+
then we suggest you create a
|
|
110
|
+
[new issue](https://github.com/jeertmans/DiffeRT/issues/new/choose).
|
|
111
|
+
You can choose from a list of templates, or open a
|
|
112
|
+
[blank issue](https://github.com/jeertmans/DiffeRT/issues/new)
|
|
113
|
+
if your issue does not fit one of the proposed topics.
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
## Local development
|
|
125
|
-
|
|
126
|
-
The following commands assume that you installed
|
|
127
|
-
the project locally with:
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
uv sync
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
and that you activated the corresponding Python virtual environment:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
. .venv/bin/activate # or .venv\Scripts\activate on Windows
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Documentation
|
|
140
|
-
|
|
141
|
-
To generate the documentation, please run the following:
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
just docs/build
|
|
145
|
-
```
|
|
115
|
+
The more precise you are in the description of your problem, the faster we will
|
|
116
|
+
be able to help you!
|
|
146
117
|
|
|
147
|
-
|
|
118
|
+
If you rather have question than a problem,
|
|
119
|
+
then it is probably best suited to ask it in the
|
|
120
|
+
[Q&A category of the discussions](https://github.com/jeertmans/DiffeRT/discussions/categories/q-a).
|
|
148
121
|
|
|
149
|
-
|
|
122
|
+
<!-- end reporting-an-issue -->
|
|
150
123
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Both Rust and Python codebases have their own tests and benchmarks.
|
|
154
|
-
|
|
155
|
-
#### Testing Rust code
|
|
156
|
-
|
|
157
|
-
You can test Rust code using Cargo:
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
cargo test
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
or benchmark it:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
cargo bench
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
#### Testing Python code
|
|
170
|
-
|
|
171
|
-
Similarly, you can test Python code with Pytest:
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
pytest
|
|
175
|
-
```
|
|
124
|
+
## Contributing
|
|
176
125
|
|
|
177
|
-
|
|
126
|
+
All types of contributions are more than welcome!
|
|
178
127
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
128
|
+
Please follow the
|
|
129
|
+
[contributing guide](https://differt.readthedocs.io/latest/contributing.html)
|
|
130
|
+
for a detailed step-by-step procedure.
|
|
182
131
|
|
|
183
132
|
## Citing
|
|
184
133
|
|
|
@@ -16,7 +16,7 @@ classifiers = [
|
|
|
16
16
|
dependencies = [
|
|
17
17
|
"beartype>=0.17.2",
|
|
18
18
|
"chex>=0.1.86",
|
|
19
|
-
"differt-core==0.0.
|
|
19
|
+
"differt-core==0.0.25",
|
|
20
20
|
"equinox>=0.11.5",
|
|
21
21
|
"filelock>=3.15.4",
|
|
22
22
|
"jax>=0.4.32",
|
|
@@ -52,7 +52,7 @@ vispy = [
|
|
|
52
52
|
vispy-backend = ["PyQt6>=6.6.1"]
|
|
53
53
|
|
|
54
54
|
[project.scripts]
|
|
55
|
-
"download-sionna-scenes" = "differt.scene.
|
|
55
|
+
"download-sionna-scenes" = "differt.scene._sionna:download_sionna_scenes"
|
|
56
56
|
|
|
57
57
|
[project.urls]
|
|
58
58
|
Changelog = "https://github.com/jeertmans/DiffeRT/releases"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Electromagnetic fields utilities."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"F",
|
|
5
|
+
"c",
|
|
6
|
+
"epsilon_0",
|
|
7
|
+
"erf",
|
|
8
|
+
"erfc",
|
|
9
|
+
"fresnel",
|
|
10
|
+
"lengths_to_delays",
|
|
11
|
+
"mu_0",
|
|
12
|
+
"path_delays",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from ._constants import c, epsilon_0, mu_0
|
|
16
|
+
from ._special import erf, erfc, fresnel
|
|
17
|
+
from ._utd import F
|
|
18
|
+
from ._utils import lengths_to_delays, path_delays
|
|
@@ -64,7 +64,7 @@ def erf(z: Inexact[Array, " *batch"]) -> Inexact[Array, " *batch"]:
|
|
|
64
64
|
|
|
65
65
|
.. plot::
|
|
66
66
|
|
|
67
|
-
>>> from differt.em
|
|
67
|
+
>>> from differt.em import erf
|
|
68
68
|
>>>
|
|
69
69
|
>>> x = jnp.linspace(-3.0, +3.0)
|
|
70
70
|
>>> y = erf(x)
|
|
@@ -76,7 +76,7 @@ def erf(z: Inexact[Array, " *batch"]) -> Inexact[Array, " *batch"]:
|
|
|
76
76
|
|
|
77
77
|
.. plotly::
|
|
78
78
|
|
|
79
|
-
>>> from differt.em
|
|
79
|
+
>>> from differt.em import erf
|
|
80
80
|
>>> from scipy.special import erf
|
|
81
81
|
>>>
|
|
82
82
|
>>> x = y = jnp.linspace(-2.0, +2.0, 200)
|
|
@@ -180,7 +180,7 @@ def erfc(z: Inexact[Array, " *batch"]) -> Inexact[Array, " *batch"]:
|
|
|
180
180
|
|
|
181
181
|
.. plot::
|
|
182
182
|
|
|
183
|
-
>>> from differt.em
|
|
183
|
+
>>> from differt.em import erfc
|
|
184
184
|
>>>
|
|
185
185
|
>>> x = jnp.linspace(-3.0, +3.0)
|
|
186
186
|
>>> y = erfc(x)
|
|
@@ -200,7 +200,7 @@ def fresnel(
|
|
|
200
200
|
Evaluate the two Fresnel integrals at the given points.
|
|
201
201
|
|
|
202
202
|
This current implementation is written using
|
|
203
|
-
the error function :func:`erf<differt.em.
|
|
203
|
+
the error function :func:`erf<differt.em.erf>`
|
|
204
204
|
see :cite:`fresnel-integrals`.
|
|
205
205
|
|
|
206
206
|
The output type (real or complex) is determined by the
|
|
@@ -217,7 +217,7 @@ def fresnel(
|
|
|
217
217
|
|
|
218
218
|
.. plot::
|
|
219
219
|
|
|
220
|
-
>>> from differt.em
|
|
220
|
+
>>> from differt.em import fresnel
|
|
221
221
|
>>>
|
|
222
222
|
>>> t = jnp.linspace(0.0, 5.0, 200)
|
|
223
223
|
>>> s, c = fresnel(t)
|
|
@@ -9,7 +9,7 @@ import jax.numpy as jnp
|
|
|
9
9
|
from beartype import beartype as typechecker
|
|
10
10
|
from jaxtyping import Array, Complex, Inexact, jaxtyped
|
|
11
11
|
|
|
12
|
-
from .
|
|
12
|
+
from ._special import erfc
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@jax.jit
|
|
@@ -58,7 +58,7 @@ def F(z: Inexact[Array, " *batch"]) -> Complex[Array, " *batch"]: # noqa: N802
|
|
|
58
58
|
The following example reproduces the same plot as in
|
|
59
59
|
:cite:`utd-mcnamara{fig. 4.16}`.
|
|
60
60
|
|
|
61
|
-
>>> from differt.em
|
|
61
|
+
>>> from differt.em import F
|
|
62
62
|
>>>
|
|
63
63
|
>>> x = jnp.logspace(-3, 1, 100)
|
|
64
64
|
>>> y = F(x)
|
|
@@ -6,9 +6,9 @@ import jax
|
|
|
6
6
|
from beartype import beartype as typechecker
|
|
7
7
|
from jaxtyping import Array, ArrayLike, Float, jaxtyped
|
|
8
8
|
|
|
9
|
-
from differt.geometry
|
|
9
|
+
from differt.geometry import path_lengths
|
|
10
10
|
|
|
11
|
-
from .
|
|
11
|
+
from ._constants import c
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@jax.jit
|
|
@@ -33,8 +33,8 @@ def lengths_to_delays(
|
|
|
33
33
|
Examples:
|
|
34
34
|
The following example shows how to compute a delay from a length.
|
|
35
35
|
|
|
36
|
-
>>> from differt.em
|
|
37
|
-
>>> from differt.em
|
|
36
|
+
>>> from differt.em import c
|
|
37
|
+
>>> from differt.em import (
|
|
38
38
|
... lengths_to_delays,
|
|
39
39
|
... )
|
|
40
40
|
>>>
|
|
@@ -69,8 +69,8 @@ def path_delays(
|
|
|
69
69
|
Examples:
|
|
70
70
|
The following example shows how to compute the delay of a very simple path.
|
|
71
71
|
|
|
72
|
-
>>> from differt.em
|
|
73
|
-
>>> from differt.em
|
|
72
|
+
>>> from differt.em import c
|
|
73
|
+
>>> from differt.em import (
|
|
74
74
|
... path_delays,
|
|
75
75
|
... )
|
|
76
76
|
>>>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Geometries for building scenes."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"Paths",
|
|
5
|
+
"TriangleMesh",
|
|
6
|
+
"assemble_paths",
|
|
7
|
+
"fibonacci_lattice",
|
|
8
|
+
"normalize",
|
|
9
|
+
"orthogonal_basis",
|
|
10
|
+
"path_lengths",
|
|
11
|
+
"rotation_matrix_along_axis",
|
|
12
|
+
"rotation_matrix_along_x_axis",
|
|
13
|
+
"rotation_matrix_along_x_axis",
|
|
14
|
+
"rotation_matrix_along_y_axis",
|
|
15
|
+
"rotation_matrix_along_z_axis",
|
|
16
|
+
"triangles_contain_vertices_assuming_inside_same_plane",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from ._paths import Paths
|
|
20
|
+
from ._triangle_mesh import (
|
|
21
|
+
TriangleMesh,
|
|
22
|
+
triangles_contain_vertices_assuming_inside_same_plane,
|
|
23
|
+
)
|
|
24
|
+
from ._utils import (
|
|
25
|
+
assemble_paths,
|
|
26
|
+
fibonacci_lattice,
|
|
27
|
+
normalize,
|
|
28
|
+
orthogonal_basis,
|
|
29
|
+
path_lengths,
|
|
30
|
+
rotation_matrix_along_axis,
|
|
31
|
+
rotation_matrix_along_x_axis,
|
|
32
|
+
rotation_matrix_along_y_axis,
|
|
33
|
+
rotation_matrix_along_z_axis,
|
|
34
|
+
)
|
differt-0.0.23/src/differt/geometry/paths.py → differt-0.0.25/src/differt/geometry/_paths.py
RENAMED
|
@@ -209,7 +209,7 @@ class Paths(eqx.Module):
|
|
|
209
209
|
|
|
210
210
|
By default, the last axis is used to match the
|
|
211
211
|
``num_path_candidates`` axis as returned by
|
|
212
|
-
:meth:`TriangleScene.compute_paths<differt.scene.
|
|
212
|
+
:meth:`TriangleScene.compute_paths<differt.scene.TriangleScene.compute_paths>`.
|
|
213
213
|
|
|
214
214
|
Returns:
|
|
215
215
|
The array of group indices.
|
|
@@ -248,7 +248,7 @@ class Paths(eqx.Module):
|
|
|
248
248
|
denoted by indices ``0`` and ``1``, and each path is made
|
|
249
249
|
of three vertices.
|
|
250
250
|
|
|
251
|
-
>>> from differt.geometry
|
|
251
|
+
>>> from differt.geometry import Paths
|
|
252
252
|
>>>
|
|
253
253
|
>>> key = jax.random.key(1234)
|
|
254
254
|
>>> key_v, key_o = jax.random.split(key, 2)
|
|
@@ -10,10 +10,10 @@ import jax.numpy as jnp
|
|
|
10
10
|
from beartype import beartype as typechecker
|
|
11
11
|
from jaxtyping import Array, ArrayLike, Bool, Float, Int, PRNGKeyArray, jaxtyped
|
|
12
12
|
|
|
13
|
-
import differt_core.geometry
|
|
13
|
+
import differt_core.geometry
|
|
14
14
|
from differt.plotting import PlotOutput, draw_mesh
|
|
15
15
|
|
|
16
|
-
from .
|
|
16
|
+
from ._utils import normalize, orthogonal_basis, rotation_matrix_along_axis
|
|
17
17
|
|
|
18
18
|
if sys.version_info >= (3, 11):
|
|
19
19
|
from typing import Self
|
|
@@ -31,7 +31,7 @@ def triangles_contain_vertices_assuming_inside_same_plane(
|
|
|
31
31
|
Return whether each triangle contains the corresponding vertex, but assuming the vertex lies in the same plane as the triangle.
|
|
32
32
|
|
|
33
33
|
This is especially useful when combined with the
|
|
34
|
-
:func:`image_method<differt.rt.image_method
|
|
34
|
+
:func:`image_method<differt.rt.image_method>`, as the paths returned
|
|
35
35
|
will also lie in the same plane as the mirrors, but may be outside of the actual reflector,
|
|
36
36
|
e.g., a triangular surface.
|
|
37
37
|
|
|
@@ -128,7 +128,7 @@ class TriangleMesh(eqx.Module):
|
|
|
128
128
|
triangles are assumed to represent a quadrilateral surface.
|
|
129
129
|
"""
|
|
130
130
|
|
|
131
|
-
def __check_init__(self) -> None: # noqa:
|
|
131
|
+
def __check_init__(self) -> None: # noqa: PLW3201
|
|
132
132
|
if self.assume_quads and (self.triangles.shape[0] % 2) != 0:
|
|
133
133
|
msg = "You cannot set 'assume_quads' to 'True' if the number of triangles is not even!"
|
|
134
134
|
raise ValueError(msg)
|
|
@@ -224,9 +224,7 @@ class TriangleMesh(eqx.Module):
|
|
|
224
224
|
return mesh
|
|
225
225
|
|
|
226
226
|
@classmethod
|
|
227
|
-
def from_core(
|
|
228
|
-
cls, core_mesh: differt_core.geometry.triangle_mesh.TriangleMesh
|
|
229
|
-
) -> Self:
|
|
227
|
+
def from_core(cls, core_mesh: differt_core.geometry.TriangleMesh) -> Self:
|
|
230
228
|
"""
|
|
231
229
|
Return a triangle mesh from a mesh created by the :mod:`differt_core` module.
|
|
232
230
|
|
|
@@ -560,7 +558,7 @@ class TriangleMesh(eqx.Module):
|
|
|
560
558
|
Returns:
|
|
561
559
|
The corresponding mesh containing only triangles.
|
|
562
560
|
"""
|
|
563
|
-
core_mesh = differt_core.geometry.
|
|
561
|
+
core_mesh = differt_core.geometry.TriangleMesh.load_obj(file)
|
|
564
562
|
return cls.from_core(core_mesh)
|
|
565
563
|
|
|
566
564
|
@classmethod
|
|
@@ -577,7 +575,7 @@ class TriangleMesh(eqx.Module):
|
|
|
577
575
|
Returns:
|
|
578
576
|
The corresponding mesh containing only triangles.
|
|
579
577
|
"""
|
|
580
|
-
core_mesh = differt_core.geometry.
|
|
578
|
+
core_mesh = differt_core.geometry.TriangleMesh.load_ply(file)
|
|
581
579
|
return cls.from_core(core_mesh)
|
|
582
580
|
|
|
583
581
|
def plot(self, **kwargs: Any) -> PlotOutput:
|
differt-0.0.23/src/differt/geometry/utils.py → differt-0.0.25/src/differt/geometry/_utils.py
RENAMED
|
@@ -81,7 +81,7 @@ def normalize(
|
|
|
81
81
|
The following examples shows how normalization works and
|
|
82
82
|
its special behavior at zero.
|
|
83
83
|
|
|
84
|
-
>>> from differt.geometry
|
|
84
|
+
>>> from differt.geometry import (
|
|
85
85
|
... normalize,
|
|
86
86
|
... )
|
|
87
87
|
>>>
|
|
@@ -124,7 +124,7 @@ def orthogonal_basis(
|
|
|
124
124
|
Examples:
|
|
125
125
|
The following example shows how this function works on basic input vectors.
|
|
126
126
|
|
|
127
|
-
>>> from differt.geometry
|
|
127
|
+
>>> from differt.geometry import (
|
|
128
128
|
... normalize,
|
|
129
129
|
... orthogonal_basis,
|
|
130
130
|
... )
|
|
@@ -167,7 +167,7 @@ def path_lengths(
|
|
|
167
167
|
Examples:
|
|
168
168
|
The following example shows how to compute the length of a very simple path.
|
|
169
169
|
|
|
170
|
-
>>> from differt.geometry
|
|
170
|
+
>>> from differt.geometry import (
|
|
171
171
|
... path_lengths,
|
|
172
172
|
... )
|
|
173
173
|
>>>
|
|
@@ -201,7 +201,7 @@ def rotation_matrix_along_x_axis(
|
|
|
201
201
|
The following example shows how to rotate xyz coordinates
|
|
202
202
|
along the x axis.
|
|
203
203
|
|
|
204
|
-
>>> from differt.geometry
|
|
204
|
+
>>> from differt.geometry import (
|
|
205
205
|
... rotation_matrix_along_x_axis,
|
|
206
206
|
... )
|
|
207
207
|
>>>
|
|
@@ -237,7 +237,7 @@ def rotation_matrix_along_y_axis(
|
|
|
237
237
|
The following example shows how to rotate xyz coordinates
|
|
238
238
|
along the y axis.
|
|
239
239
|
|
|
240
|
-
>>> from differt.geometry
|
|
240
|
+
>>> from differt.geometry import (
|
|
241
241
|
... rotation_matrix_along_y_axis,
|
|
242
242
|
... )
|
|
243
243
|
>>>
|
|
@@ -273,7 +273,7 @@ def rotation_matrix_along_z_axis(
|
|
|
273
273
|
The following example shows how to rotate xyz coordinates
|
|
274
274
|
along the z axis.
|
|
275
275
|
|
|
276
|
-
>>> from differt.geometry
|
|
276
|
+
>>> from differt.geometry import (
|
|
277
277
|
... rotation_matrix_along_z_axis,
|
|
278
278
|
... )
|
|
279
279
|
>>>
|
|
@@ -311,7 +311,7 @@ def rotation_matrix_along_axis(
|
|
|
311
311
|
The following example shows how to rotate xyz coordinates
|
|
312
312
|
along a given axis.
|
|
313
313
|
|
|
314
|
-
>>> from differt.geometry
|
|
314
|
+
>>> from differt.geometry import (
|
|
315
315
|
... normalize,
|
|
316
316
|
... rotation_matrix_along_axis,
|
|
317
317
|
... )
|
|
@@ -324,7 +324,7 @@ def rotation_matrix_along_axis(
|
|
|
324
324
|
In the following example, we show the importance of using a unit
|
|
325
325
|
vector.
|
|
326
326
|
|
|
327
|
-
>>> from differt.geometry
|
|
327
|
+
>>> from differt.geometry import (
|
|
328
328
|
... rotation_matrix_along_axis,
|
|
329
329
|
... )
|
|
330
330
|
>>>
|
|
@@ -380,7 +380,7 @@ def fibonacci_lattice(
|
|
|
380
380
|
|
|
381
381
|
.. plotly::
|
|
382
382
|
|
|
383
|
-
>>> from differt.geometry
|
|
383
|
+
>>> from differt.geometry import (
|
|
384
384
|
... fibonacci_lattice,
|
|
385
385
|
... )
|
|
386
386
|
>>> from differt.plotting import draw_markers
|
|
@@ -288,7 +288,7 @@ def draw_rays(
|
|
|
288
288
|
|
|
289
289
|
.. plotly::
|
|
290
290
|
|
|
291
|
-
>>> from differt.geometry
|
|
291
|
+
>>> from differt.geometry import fibonacci_lattice
|
|
292
292
|
>>> from differt.plotting import draw_rays
|
|
293
293
|
>>>
|
|
294
294
|
>>> ray_origins = jnp.zeros(3)
|
|
@@ -479,7 +479,7 @@ def draw_image(
|
|
|
479
479
|
**kwargs: Any,
|
|
480
480
|
) -> Canvas | MplFigure | Figure: # type: ignore[reportInvalidTypeForm]
|
|
481
481
|
"""
|
|
482
|
-
Plot a 2D image on a 3D canvas, at
|
|
482
|
+
Plot a 2D image on a 3D canvas, at a fixed z-coordinate.
|
|
483
483
|
|
|
484
484
|
Args:
|
|
485
485
|
data: The image data array. Can be grayscale, RGB or RGBA.
|
|
@@ -635,7 +635,7 @@ def draw_contour( # noqa: PLR0917
|
|
|
635
635
|
**kwargs: Any,
|
|
636
636
|
) -> Canvas | MplFigure | Figure: # type: ignore[reportInvalidTypeForm]
|
|
637
637
|
"""
|
|
638
|
-
Plot a 2D contour on a 3D canvas, at
|
|
638
|
+
Plot a 2D contour on a 3D canvas, at a fixed z-coordinate.
|
|
639
639
|
|
|
640
640
|
Args:
|
|
641
641
|
data: The values over which the contour is drawn.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Ray Tracing utilities."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"SizedIterator",
|
|
5
|
+
"consecutive_vertices_are_on_same_side_of_mirrors",
|
|
6
|
+
"fermat_path_on_planar_mirrors",
|
|
7
|
+
"generate_all_path_candidates",
|
|
8
|
+
"generate_all_path_candidates_chunks_iter",
|
|
9
|
+
"generate_all_path_candidates_iter",
|
|
10
|
+
"image_method",
|
|
11
|
+
"image_of_vertices_with_respect_to_mirrors",
|
|
12
|
+
"intersection_of_rays_with_planes",
|
|
13
|
+
"rays_intersect_any_triangle",
|
|
14
|
+
"rays_intersect_triangles",
|
|
15
|
+
"triangles_visible_from_vertices",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
from ._fermat import fermat_path_on_planar_mirrors
|
|
19
|
+
from ._image_method import (
|
|
20
|
+
consecutive_vertices_are_on_same_side_of_mirrors,
|
|
21
|
+
image_method,
|
|
22
|
+
image_of_vertices_with_respect_to_mirrors,
|
|
23
|
+
intersection_of_rays_with_planes,
|
|
24
|
+
)
|
|
25
|
+
from ._utils import (
|
|
26
|
+
SizedIterator,
|
|
27
|
+
generate_all_path_candidates,
|
|
28
|
+
generate_all_path_candidates_chunks_iter,
|
|
29
|
+
generate_all_path_candidates_iter,
|
|
30
|
+
rays_intersect_any_triangle,
|
|
31
|
+
rays_intersect_triangles,
|
|
32
|
+
triangles_visible_from_vertices,
|
|
33
|
+
)
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Path tracing utilities that utilize Fermat's principle.
|
|
3
|
-
|
|
4
|
-
Fermat's principle states that the path taken by a ray between two
|
|
5
|
-
given points is the path that can be traveled in the least time
|
|
6
|
-
:cite:`fermat-principle`. In a homogeneous medium,
|
|
7
|
-
this means that the path of least time is also the path of last distance.
|
|
8
|
-
|
|
9
|
-
As a result, this module offers minimization methods for finding ray paths.
|
|
10
|
-
"""
|
|
1
|
+
"""Path tracing utilities that utilize Fermat's principle."""
|
|
11
2
|
|
|
12
3
|
from typing import Any
|
|
13
4
|
|
|
@@ -16,7 +7,7 @@ import jax.numpy as jnp
|
|
|
16
7
|
from beartype import beartype as typechecker
|
|
17
8
|
from jaxtyping import Array, Float, jaxtyped
|
|
18
9
|
|
|
19
|
-
from differt.geometry
|
|
10
|
+
from differt.geometry import orthogonal_basis
|
|
20
11
|
from differt.utils import minimize
|
|
21
12
|
|
|
22
13
|
|
|
@@ -61,7 +52,7 @@ def fermat_path_on_planar_mirrors(
|
|
|
61
52
|
The paths do not contain the starting and ending vertices.
|
|
62
53
|
|
|
63
54
|
You can easily create the complete ray paths using
|
|
64
|
-
:func:`assemble_paths<differt.geometry.
|
|
55
|
+
:func:`assemble_paths<differt.geometry.assemble_paths>`:
|
|
65
56
|
|
|
66
57
|
.. code-block:: python
|
|
67
58
|
|
differt-0.0.23/src/differt/rt/image_method.py → differt-0.0.25/src/differt/rt/_image_method.py
RENAMED
|
@@ -1,89 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Path tracing utilities that utilize the Image Method.
|
|
3
|
-
|
|
4
|
-
The Image Method is a very simple but effective path tracing technique
|
|
5
|
-
that can rapidly compute a ray path undergoing a series
|
|
6
|
-
of specular reflections on a pre-defined list of mirrors.
|
|
7
|
-
|
|
8
|
-
The method assumes infinitely long mirrors, and will return invalid
|
|
9
|
-
paths in some degenerated cases such as consecutive colinear mirrors,
|
|
10
|
-
or impossible configurations. It is the user's responsibility to make
|
|
11
|
-
sure that the returned path is correct.
|
|
12
|
-
|
|
13
|
-
Otherwise, the returned path will, for each reflection, have equal angles
|
|
14
|
-
of incidence and of reflection.
|
|
15
|
-
|
|
16
|
-
Examples:
|
|
17
|
-
The following image shows how the Image Method (IM) can be applied
|
|
18
|
-
to find a path between two nodes (i.e., BS and UE).
|
|
19
|
-
|
|
20
|
-
.. figure:: ../_static/image-method.svg
|
|
21
|
-
:width: 70%
|
|
22
|
-
:align: center
|
|
23
|
-
:alt: Image Method example.
|
|
24
|
-
|
|
25
|
-
Example application of IM in RT. The method determines the only
|
|
26
|
-
valid path that can be taken to join BS and UE with, in between, reflection with
|
|
27
|
-
two mirrors (the interaction order is important). First, the consecutive images
|
|
28
|
-
of the BS are determined through each mirror, using line symmetry. Second,
|
|
29
|
-
intersections with mirrors are computed backward, `i.e.`, from last mirror to
|
|
30
|
-
first, by joining the UE, then the intersections points, with the images of the
|
|
31
|
-
BS. Finally, the valid path can be obtained by joining BS, the intermediary
|
|
32
|
-
intersection points, and the UE :cite:`mpt-eucap2023{fig. 5}`.
|
|
33
|
-
|
|
34
|
-
Next, we show how to reproduce the above results using :func:`image_method`.
|
|
35
|
-
|
|
36
|
-
.. plotly::
|
|
37
|
-
|
|
38
|
-
>>> from differt.geometry.utils import normalize
|
|
39
|
-
>>> from differt.geometry.triangle_mesh import TriangleMesh
|
|
40
|
-
>>> from differt.plotting import draw_markers, draw_paths, reuse
|
|
41
|
-
>>> from differt.rt.image_method import image_method
|
|
42
|
-
>>>
|
|
43
|
-
>>> from_vertex = jnp.array([+2.0, -1.0, +0.0])
|
|
44
|
-
>>> to_vertex = jnp.array([+2.0, +4.0, +0.0])
|
|
45
|
-
>>> mirror_vertices = jnp.array([
|
|
46
|
-
... [3.0, 3.0, 0.0],
|
|
47
|
-
... [4.0, 3.4, 0.0],
|
|
48
|
-
... ])
|
|
49
|
-
>>> mirror_normals = jnp.array([
|
|
50
|
-
... [+1.0, -1.0, +0.0],
|
|
51
|
-
... [-1.0, +0.0, +0.0],
|
|
52
|
-
... ])
|
|
53
|
-
>>> mirror_normals, _ = normalize(mirror_normals)
|
|
54
|
-
>>> path = image_method(
|
|
55
|
-
... from_vertex,
|
|
56
|
-
... to_vertex,
|
|
57
|
-
... mirror_vertices,
|
|
58
|
-
... mirror_normals,
|
|
59
|
-
... )
|
|
60
|
-
>>> with reuse(backend="plotly") as fig: # doctest: +SKIP
|
|
61
|
-
... TriangleMesh.plane(
|
|
62
|
-
... mirror_vertices[0], normal=mirror_normals[0], rotate=-0.954
|
|
63
|
-
... ).plot(color="red")
|
|
64
|
-
... TriangleMesh.plane(mirror_vertices[1], normal=mirror_normals[1]).plot(
|
|
65
|
-
... color="red"
|
|
66
|
-
... )
|
|
67
|
-
...
|
|
68
|
-
... full_path = jnp.concatenate(
|
|
69
|
-
... (
|
|
70
|
-
... from_vertex[None, :],
|
|
71
|
-
... path,
|
|
72
|
-
... to_vertex[None, :],
|
|
73
|
-
... ),
|
|
74
|
-
... axis=0,
|
|
75
|
-
... )
|
|
76
|
-
... draw_paths(full_path, marker={"color": "green"}, name="Final path")
|
|
77
|
-
... markers = jnp.vstack((from_vertex, to_vertex))
|
|
78
|
-
... draw_markers(
|
|
79
|
-
... markers,
|
|
80
|
-
... labels=["BS", "UE"],
|
|
81
|
-
... marker={"color": "black"},
|
|
82
|
-
... name="BS/UE",
|
|
83
|
-
... )
|
|
84
|
-
... fig.update_layout(scene_aspectmode="data")
|
|
85
|
-
>>> fig # doctest: +SKIP
|
|
86
|
-
"""
|
|
1
|
+
"""Path tracing utilities that utilize the Image Method."""
|
|
87
2
|
# ruff: noqa: ERA001
|
|
88
3
|
|
|
89
4
|
import chex
|
|
@@ -119,7 +34,7 @@ def image_of_vertices_with_respect_to_mirrors(
|
|
|
119
34
|
a batch of random vertices. Here, normal vectors do not have a unit length,
|
|
120
35
|
but they should have if you want an interpretable result.
|
|
121
36
|
|
|
122
|
-
>>> from differt.rt
|
|
37
|
+
>>> from differt.rt import (
|
|
123
38
|
... image_of_vertices_with_respect_to_mirrors,
|
|
124
39
|
... )
|
|
125
40
|
>>>
|
|
@@ -213,6 +128,18 @@ def image_method(
|
|
|
213
128
|
"""
|
|
214
129
|
Return the ray paths between pairs of vertices, that reflect on a given list of mirrors in between.
|
|
215
130
|
|
|
131
|
+
The Image Method is a very simple but effective path tracing technique
|
|
132
|
+
that can rapidly compute a ray path undergoing a series
|
|
133
|
+
of specular reflections on a pre-defined list of mirrors.
|
|
134
|
+
|
|
135
|
+
The method assumes infinitely long mirrors, and will return invalid
|
|
136
|
+
paths in some degenerated cases such as consecutive colinear mirrors,
|
|
137
|
+
or impossible configurations. It is the user's responsibility to make
|
|
138
|
+
sure that the returned path is correct.
|
|
139
|
+
|
|
140
|
+
Otherwise, the returned path will, for each reflection, have equal angles
|
|
141
|
+
of incidence and of reflection.
|
|
142
|
+
|
|
216
143
|
Warning:
|
|
217
144
|
NaNs and infinity values should be treated as invalid paths, and will naturally
|
|
218
145
|
occur when image paths are impossible to trace, e.g., when a mirror
|
|
@@ -239,7 +166,7 @@ def image_method(
|
|
|
239
166
|
The paths do not contain the starting and ending vertices.
|
|
240
167
|
|
|
241
168
|
You can easily create the complete ray paths using
|
|
242
|
-
:func:`assemble_paths<differt.geometry.
|
|
169
|
+
:func:`assemble_paths<differt.geometry.assemble_paths>`:
|
|
243
170
|
|
|
244
171
|
.. code-block:: python
|
|
245
172
|
|
|
@@ -256,6 +183,76 @@ def image_method(
|
|
|
256
183
|
to_vertices[..., None, :],
|
|
257
184
|
)
|
|
258
185
|
|
|
186
|
+
Examples:
|
|
187
|
+
The following image shows how the Image Method (IM) can be applied
|
|
188
|
+
to find a path between two nodes (i.e., BS and UE).
|
|
189
|
+
|
|
190
|
+
.. figure:: ../../_static/image-method.svg
|
|
191
|
+
:width: 70%
|
|
192
|
+
:align: center
|
|
193
|
+
:alt: Image Method example.
|
|
194
|
+
|
|
195
|
+
Example application of IM in RT. The method determines the only
|
|
196
|
+
valid path that can be taken to join BS and UE with, in between, reflection with
|
|
197
|
+
two mirrors (the interaction order is important). First, the consecutive images
|
|
198
|
+
of the BS are determined through each mirror, using line symmetry. Second,
|
|
199
|
+
intersections with mirrors are computed backward, `i.e.`, from last mirror to
|
|
200
|
+
first, by joining the UE, then the intersections points, with the images of the
|
|
201
|
+
BS. Finally, the valid path can be obtained by joining BS, the intermediary
|
|
202
|
+
intersection points, and the UE :cite:`mpt-eucap2023{fig. 5}`.
|
|
203
|
+
|
|
204
|
+
Next, we show how to reproduce the above results using :func:`image_method`.
|
|
205
|
+
|
|
206
|
+
.. plotly::
|
|
207
|
+
|
|
208
|
+
>>> from differt.geometry import TriangleMesh, normalize
|
|
209
|
+
>>> from differt.plotting import draw_markers, draw_paths, reuse
|
|
210
|
+
>>> from differt.rt import image_method
|
|
211
|
+
>>>
|
|
212
|
+
>>> from_vertex = jnp.array([+2.0, -1.0, +0.0])
|
|
213
|
+
>>> to_vertex = jnp.array([+2.0, +4.0, +0.0])
|
|
214
|
+
>>> mirror_vertices = jnp.array([
|
|
215
|
+
... [3.0, 3.0, 0.0],
|
|
216
|
+
... [4.0, 3.4, 0.0],
|
|
217
|
+
... ])
|
|
218
|
+
>>> mirror_normals = jnp.array([
|
|
219
|
+
... [+1.0, -1.0, +0.0],
|
|
220
|
+
... [-1.0, +0.0, +0.0],
|
|
221
|
+
... ])
|
|
222
|
+
>>> mirror_normals, _ = normalize(mirror_normals)
|
|
223
|
+
>>> path = image_method(
|
|
224
|
+
... from_vertex,
|
|
225
|
+
... to_vertex,
|
|
226
|
+
... mirror_vertices,
|
|
227
|
+
... mirror_normals,
|
|
228
|
+
... )
|
|
229
|
+
>>> with reuse(backend="plotly") as fig: # doctest: +SKIP
|
|
230
|
+
... TriangleMesh.plane(
|
|
231
|
+
... mirror_vertices[0], normal=mirror_normals[0], rotate=-0.954
|
|
232
|
+
... ).plot(color="red")
|
|
233
|
+
... TriangleMesh.plane(
|
|
234
|
+
... mirror_vertices[1], normal=mirror_normals[1]
|
|
235
|
+
... ).plot(color="red")
|
|
236
|
+
...
|
|
237
|
+
... full_path = jnp.concatenate(
|
|
238
|
+
... (
|
|
239
|
+
... from_vertex[None, :],
|
|
240
|
+
... path,
|
|
241
|
+
... to_vertex[None, :],
|
|
242
|
+
... ),
|
|
243
|
+
... axis=0,
|
|
244
|
+
... )
|
|
245
|
+
... draw_paths(full_path, marker={"color": "green"}, name="Final path")
|
|
246
|
+
... markers = jnp.vstack((from_vertex, to_vertex))
|
|
247
|
+
... draw_markers(
|
|
248
|
+
... markers,
|
|
249
|
+
... labels=["BS", "UE"],
|
|
250
|
+
... marker={"color": "black"},
|
|
251
|
+
... name="BS/UE",
|
|
252
|
+
... )
|
|
253
|
+
... fig.update_layout(scene_aspectmode="data")
|
|
254
|
+
>>> fig # doctest: +SKIP
|
|
255
|
+
|
|
259
256
|
"""
|
|
260
257
|
# Put 'num_mirrors' axis as leading axis
|
|
261
258
|
mirror_vertices = jnp.moveaxis(mirror_vertices, -2, 0)
|
|
@@ -37,8 +37,8 @@ import jax.numpy as jnp
|
|
|
37
37
|
from beartype import beartype as typechecker
|
|
38
38
|
from jaxtyping import Array, ArrayLike, Bool, Float, Int, jaxtyped
|
|
39
39
|
|
|
40
|
-
from differt.geometry
|
|
41
|
-
from differt_core.rt
|
|
40
|
+
from differt.geometry import fibonacci_lattice
|
|
41
|
+
from differt_core.rt import CompleteGraph
|
|
42
42
|
|
|
43
43
|
if sys.version_info >= (3, 11):
|
|
44
44
|
from typing import Self
|
|
@@ -63,7 +63,7 @@ class SizedIterator(Iterator, Sized, Generic[_T]):
|
|
|
63
63
|
Examples:
|
|
64
64
|
The following example shows how to create a sized iterator.
|
|
65
65
|
|
|
66
|
-
>>> from differt.rt
|
|
66
|
+
>>> from differt.rt import SizedIterator
|
|
67
67
|
>>> l = [1, 2, 3, 4, 5]
|
|
68
68
|
>>> it = SizedIterator(iter=iter(l), size=5)
|
|
69
69
|
>>> len(it)
|
|
@@ -76,17 +76,17 @@ class SizedIterator(Iterator, Sized, Generic[_T]):
|
|
|
76
76
|
|
|
77
77
|
__slots__ = ("_iter", "_size")
|
|
78
78
|
|
|
79
|
-
def __init__(self, iter: Iterator[_T], size: int | Callable[[], int]) -> None: # noqa: A002
|
|
79
|
+
def __init__(self, iter: Iterator[_T], size: int | Callable[[], int]) -> None: # noqa: A002
|
|
80
80
|
self._iter = iter
|
|
81
81
|
self._size = size
|
|
82
82
|
|
|
83
|
-
def __iter__(self) -> Self:
|
|
83
|
+
def __iter__(self) -> Self:
|
|
84
84
|
return self
|
|
85
85
|
|
|
86
|
-
def __next__(self) -> _T:
|
|
86
|
+
def __next__(self) -> _T:
|
|
87
87
|
return next(self._iter)
|
|
88
88
|
|
|
89
|
-
def __len__(self) -> int:
|
|
89
|
+
def __len__(self) -> int:
|
|
90
90
|
if isinstance(self._size, int):
|
|
91
91
|
return self._size
|
|
92
92
|
return self._size()
|
|
@@ -225,16 +225,16 @@ def rays_intersect_triangles(
|
|
|
225
225
|
.. plotly::
|
|
226
226
|
|
|
227
227
|
>>> import equinox as eqx
|
|
228
|
-
>>> from differt.geometry
|
|
228
|
+
>>> from differt.geometry import fibonacci_lattice
|
|
229
229
|
>>> from differt.plotting import draw_rays
|
|
230
|
-
>>> from differt.rt
|
|
230
|
+
>>> from differt.rt import (
|
|
231
231
|
... rays_intersect_triangles,
|
|
232
232
|
... )
|
|
233
|
-
>>> from differt.scene
|
|
233
|
+
>>> from differt.scene import (
|
|
234
234
|
... get_sionna_scene,
|
|
235
235
|
... download_sionna_scenes,
|
|
236
236
|
... )
|
|
237
|
-
>>> from differt.scene
|
|
237
|
+
>>> from differt.scene import TriangleScene
|
|
238
238
|
>>>
|
|
239
239
|
>>> download_sionna_scenes()
|
|
240
240
|
>>> file = get_sionna_scene("simple_street_canyon")
|
|
@@ -398,7 +398,7 @@ def triangles_visible_from_vertices(
|
|
|
398
398
|
Return whether triangles are visible from vertex positions.
|
|
399
399
|
|
|
400
400
|
This function uses ray launching and
|
|
401
|
-
:func:`fibonacci_lattice<differt.geometry.
|
|
401
|
+
:func:`fibonacci_lattice<differt.geometry.fibonacci_lattice>` to estimate
|
|
402
402
|
whether a given triangle can be reached from a specific vertex, i.e., with a ray path,
|
|
403
403
|
without interacting with any other triangle facet.
|
|
404
404
|
|
|
@@ -423,14 +423,14 @@ def triangles_visible_from_vertices(
|
|
|
423
423
|
.. plotly::
|
|
424
424
|
|
|
425
425
|
>>> import equinox as eqx
|
|
426
|
-
>>> from differt.rt
|
|
426
|
+
>>> from differt.rt import (
|
|
427
427
|
... triangles_visible_from_vertices,
|
|
428
428
|
... )
|
|
429
|
-
>>> from differt.scene
|
|
429
|
+
>>> from differt.scene import (
|
|
430
430
|
... get_sionna_scene,
|
|
431
431
|
... download_sionna_scenes,
|
|
432
432
|
... )
|
|
433
|
-
>>> from differt.scene
|
|
433
|
+
>>> from differt.scene import TriangleScene
|
|
434
434
|
>>>
|
|
435
435
|
>>> download_sionna_scenes()
|
|
436
436
|
>>> file = get_sionna_scene("simple_street_canyon")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Scene utilities."""
|
|
2
|
+
|
|
3
|
+
__all__ = (
|
|
4
|
+
"TriangleScene",
|
|
5
|
+
"download_sionna_scenes",
|
|
6
|
+
"get_sionna_scene",
|
|
7
|
+
"list_sionna_scenes",
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from ._sionna import download_sionna_scenes, get_sionna_scene, list_sionna_scenes
|
|
11
|
+
from ._triangle_scene import TriangleScene
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Provide a compatibility layer with Sionna's scenes.
|
|
3
|
-
|
|
4
|
-
Sionna uses the simple XML-based format from Mitsuba 3.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
__all__ = (
|
|
8
|
-
"download_sionna_scenes",
|
|
9
|
-
"get_sionna_scene",
|
|
10
|
-
"list_sionna_scenes",
|
|
11
|
-
)
|
|
1
|
+
"""Sionna utitilies."""
|
|
12
2
|
|
|
13
3
|
import tarfile
|
|
14
4
|
import tempfile
|
|
@@ -17,21 +17,19 @@ from jax.sharding import Mesh
|
|
|
17
17
|
from jax.sharding import PartitionSpec as P # noqa: N814
|
|
18
18
|
from jaxtyping import Array, ArrayLike, Bool, Float, Int, jaxtyped
|
|
19
19
|
|
|
20
|
-
import differt_core.scene
|
|
21
|
-
from differt.geometry
|
|
22
|
-
|
|
20
|
+
import differt_core.scene
|
|
21
|
+
from differt.geometry import (
|
|
22
|
+
Paths,
|
|
23
23
|
TriangleMesh,
|
|
24
|
+
assemble_paths,
|
|
24
25
|
)
|
|
25
|
-
from differt.geometry.utils import assemble_paths
|
|
26
26
|
from differt.plotting import PlotOutput, draw_markers, reuse
|
|
27
|
-
from differt.rt
|
|
28
|
-
consecutive_vertices_are_on_same_side_of_mirrors,
|
|
29
|
-
image_method,
|
|
30
|
-
)
|
|
31
|
-
from differt.rt.utils import (
|
|
27
|
+
from differt.rt import (
|
|
32
28
|
SizedIterator,
|
|
29
|
+
consecutive_vertices_are_on_same_side_of_mirrors,
|
|
33
30
|
generate_all_path_candidates,
|
|
34
31
|
generate_all_path_candidates_chunks_iter,
|
|
32
|
+
image_method,
|
|
35
33
|
rays_intersect_any_triangle,
|
|
36
34
|
rays_intersect_triangles,
|
|
37
35
|
)
|
|
@@ -281,9 +279,9 @@ class TriangleScene(eqx.Module):
|
|
|
281
279
|
|
|
282
280
|
def set_assume_quads(self, flag: bool = True) -> Self:
|
|
283
281
|
"""
|
|
284
|
-
Return a copy of this scene with :attr:`TriangleMesh.assume_quads<differt.geometry.
|
|
282
|
+
Return a copy of this scene with :attr:`TriangleMesh.assume_quads<differt.geometry.TriangleMesh.assume_quads>` set to ``flag``.
|
|
285
283
|
|
|
286
|
-
This is simply a convenient wrapper around :meth:`TriangleMesh.set_assume_quads<differt.geometry.
|
|
284
|
+
This is simply a convenient wrapper around :meth:`TriangleMesh.set_assume_quads<differt.geometry.TriangleMesh.set_assume_quads>`.
|
|
287
285
|
|
|
288
286
|
Args:
|
|
289
287
|
flag: The new flag value.
|
|
@@ -444,9 +442,7 @@ class TriangleScene(eqx.Module):
|
|
|
444
442
|
)
|
|
445
443
|
|
|
446
444
|
@classmethod
|
|
447
|
-
def from_core(
|
|
448
|
-
cls, core_scene: differt_core.scene.triangle_scene.TriangleScene
|
|
449
|
-
) -> Self:
|
|
445
|
+
def from_core(cls, core_scene: differt_core.scene.TriangleScene) -> Self:
|
|
450
446
|
"""
|
|
451
447
|
Return a triangle scene from a scene created by the :mod:`differt_core` module.
|
|
452
448
|
|
|
@@ -466,7 +462,7 @@ class TriangleScene(eqx.Module):
|
|
|
466
462
|
Load a triangle scene from a XML file.
|
|
467
463
|
|
|
468
464
|
This method uses
|
|
469
|
-
:meth:`SionnaScene.load_xml<differt_core.scene.
|
|
465
|
+
:meth:`SionnaScene.load_xml<differt_core.scene.SionnaScene.load_xml>`
|
|
470
466
|
internally.
|
|
471
467
|
|
|
472
468
|
Args:
|
|
@@ -475,7 +471,7 @@ class TriangleScene(eqx.Module):
|
|
|
475
471
|
Returns:
|
|
476
472
|
The corresponding scene containing only triangle meshes.
|
|
477
473
|
"""
|
|
478
|
-
core_scene = differt_core.scene.
|
|
474
|
+
core_scene = differt_core.scene.TriangleScene.load_xml(file)
|
|
479
475
|
return cls.from_core(core_scene)
|
|
480
476
|
|
|
481
477
|
@overload
|
|
@@ -533,7 +529,7 @@ class TriangleScene(eqx.Module):
|
|
|
533
529
|
|
|
534
530
|
Note:
|
|
535
531
|
Currently, only :abbr:`LOS (line of sight)` and fixed ``order`` reflection paths are computed,
|
|
536
|
-
using the :func:`image_method<differt.rt.image_method
|
|
532
|
+
using the :func:`image_method<differt.rt.image_method>`. More types of interactions
|
|
537
533
|
and path tracing methods will be added in the future, so stay tuned!
|
|
538
534
|
|
|
539
535
|
Args:
|
|
@@ -546,17 +542,20 @@ class TriangleScene(eqx.Module):
|
|
|
546
542
|
Unused if ``path_candidates`` is provided.
|
|
547
543
|
path_candidates: An optional array of path candidates, see :ref:`path_candidates`.
|
|
548
544
|
|
|
549
|
-
This is helpful to only generate paths on a subset of the scene.
|
|
545
|
+
This is helpful to only generate paths on a subset of the scene. E.g., this
|
|
546
|
+
is used in :ref:`sampling-paths` to test a specific set of path candidates
|
|
547
|
+
generated from a Machine Learning model.
|
|
550
548
|
|
|
551
|
-
If
|
|
549
|
+
If :attr:`self.mesh.assume_quads<differt.geometry.TriangleMesh.assume_quads>`
|
|
550
|
+
is :data:`True`, then path candidates are
|
|
552
551
|
rounded down toward the nearest even value.
|
|
553
552
|
parallel: If :data:`True`, ray tracing is performed in parallel across all available
|
|
554
553
|
devices. The number of transmitters times the number of receivers
|
|
555
554
|
**must** be a multiple of :func:`jax.device_count`, otherwise an error is raised.
|
|
556
555
|
epsilon: Tolelance for checking ray / objects intersection, see
|
|
557
|
-
:func:`rays_intersect_triangles<differt.rt.
|
|
556
|
+
:func:`rays_intersect_triangles<differt.rt.rays_intersect_triangles>`.
|
|
558
557
|
hit_tol: Tolerance for checking blockage (i.e., obstruction), see
|
|
559
|
-
:func:`rays_intersect_any_triangle<differt.rt.
|
|
558
|
+
:func:`rays_intersect_any_triangle<differt.rt.rays_intersect_any_triangle>`.
|
|
560
559
|
min_len: Minimal (squared) length that each path segment must have for a path to be valid.
|
|
561
560
|
|
|
562
561
|
If not specified, the default is ten times the epsilon value
|
|
@@ -651,7 +650,7 @@ class TriangleScene(eqx.Module):
|
|
|
651
650
|
rx_kwargs: A mapping of keyword arguments passed to
|
|
652
651
|
:func:`draw_markers<differt.plotting.draw_markers>`.
|
|
653
652
|
mesh_kwargs: A mapping of keyword arguments passed to
|
|
654
|
-
:meth:`TriangleMesh.plot<differt.geometry.
|
|
653
|
+
:meth:`TriangleMesh.plot<differt.geometry.TriangleMesh.plot>`.
|
|
655
654
|
kwargs: Keyword arguments passed to
|
|
656
655
|
:func:`reuse<differt.plotting.reuse>`.
|
|
657
656
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Electromagnetic fields utilities."""
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Ray Tracing utilities."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|