differt 0.0.24__tar.gz → 0.0.26__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.24 → differt-0.0.26}/.gitignore +2 -0
- {differt-0.0.24 → differt-0.0.26}/PKG-INFO +37 -89
- {differt-0.0.24 → differt-0.0.26}/pyproject.toml +2 -2
- differt-0.0.26/src/differt/_version.py +6 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/em/_special.py +0 -14
- {differt-0.0.24 → differt-0.0.26}/src/differt/em/_utd.py +0 -6
- {differt-0.0.24 → differt-0.0.26}/src/differt/em/_utils.py +0 -2
- {differt-0.0.24 → differt-0.0.26}/src/differt/geometry/__init__.py +11 -1
- {differt-0.0.24 → differt-0.0.26}/src/differt/geometry/_paths.py +103 -9
- {differt-0.0.24 → differt-0.0.26}/src/differt/geometry/_triangle_mesh.py +24 -6
- {differt-0.0.24 → differt-0.0.26}/src/differt/geometry/_utils.py +345 -8
- {differt-0.0.24 → differt-0.0.26}/src/differt/plotting/_core.py +48 -62
- {differt-0.0.24 → differt-0.0.26}/src/differt/plotting/_utils.py +7 -7
- {differt-0.0.24 → differt-0.0.26}/src/differt/rt/__init__.py +2 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/rt/_fermat.py +0 -2
- {differt-0.0.24 → differt-0.0.26}/src/differt/rt/_image_method.py +11 -13
- {differt-0.0.24 → differt-0.0.26}/src/differt/rt/_utils.py +88 -38
- {differt-0.0.24 → differt-0.0.26}/src/differt/scene/_sionna.py +0 -2
- {differt-0.0.24 → differt-0.0.26}/src/differt/scene/_triangle_scene.py +382 -51
- {differt-0.0.24 → differt-0.0.26}/src/differt/utils.py +79 -23
- differt-0.0.24/src/differt/_version.py +0 -8
- {differt-0.0.24 → differt-0.0.26}/LICENSE.md +0 -0
- {differt-0.0.24 → differt-0.0.26}/README.md +0 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/__init__.py +0 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/em/__init__.py +0 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/em/_constants.py +0 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/plotting/__init__.py +0 -0
- {differt-0.0.24 → differt-0.0.26}/src/differt/scene/__init__.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.26
|
|
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
|
|
@@ -8,8 +8,7 @@ Project-URL: Founding, https://github.com/sponsors/jeertmans
|
|
|
8
8
|
Project-URL: Homepage, https://github.com/jeertmans/DiffeRT
|
|
9
9
|
Project-URL: Repository, https://github.com/jeertmans/DiffeRT
|
|
10
10
|
Author-email: Jérome Eertmans <jeertmans@icloud.com>
|
|
11
|
-
License
|
|
12
|
-
License-File: LICENSE.md
|
|
11
|
+
License: MIT
|
|
13
12
|
Keywords: differentiable,jax,propagation,radio,ray tracing
|
|
14
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
@@ -19,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
19
|
Classifier: Topic :: Scientific/Engineering
|
|
21
20
|
Requires-Python: >=3.10
|
|
22
|
-
Requires-Dist: beartype>=0.
|
|
21
|
+
Requires-Dist: beartype>=0.19.0
|
|
23
22
|
Requires-Dist: chex>=0.1.86
|
|
24
|
-
Requires-Dist: differt-core==0.0.
|
|
23
|
+
Requires-Dist: differt-core==0.0.26
|
|
25
24
|
Requires-Dist: equinox>=0.11.5
|
|
26
25
|
Requires-Dist: filelock>=3.15.4
|
|
27
26
|
Requires-Dist: jax>=0.4.32
|
|
@@ -74,9 +73,11 @@ Description-Content-Type: text/markdown
|
|
|
74
73
|
## Usage
|
|
75
74
|
|
|
76
75
|
> **WARNING:**
|
|
77
|
-
> Until this package reaches version `
|
|
78
|
-
> should be expected.
|
|
79
|
-
>
|
|
76
|
+
> Until this package reaches version `v0.1.0`, breaking changes
|
|
77
|
+
> should be expected.
|
|
78
|
+
> Checkout the [v0.1.0](https://github.com/jeertmans/DiffeRT/milestone/1)
|
|
79
|
+
> and [v1.0.0](https://github.com/jeertmans/DiffeRT/milestone/2) milestones for future
|
|
80
|
+
> features.
|
|
80
81
|
>
|
|
81
82
|
> If you have any suggestion regarding the development of this package,
|
|
82
83
|
> please open an [issue](https://github.com/jeertmans/DiffeRT/issues).
|
|
@@ -88,97 +89,44 @@ pip install differt
|
|
|
88
89
|
```
|
|
89
90
|
|
|
90
91
|
We provide pre-built binaries for most platforms. If you want (or need)
|
|
91
|
-
to build the package from the source distribution,
|
|
92
|
-
|
|
92
|
+
to build the package from the source distribution,
|
|
93
|
+
or want to customize the installation (e.g., with GPU support), check out the
|
|
94
|
+
[installation guide](https://differt.readthedocs.io/latest/installation.html).
|
|
93
95
|
|
|
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
|
|
96
|
+
### Reporting an issue
|
|
108
97
|
|
|
109
|
-
|
|
98
|
+
<!-- start reporting-an-issue -->
|
|
110
99
|
|
|
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.
|
|
100
|
+
If you think you found a bug,
|
|
101
|
+
an error in the documentation,
|
|
102
|
+
or wish there was some feature that is currently missing,
|
|
103
|
+
we would love to hear from you!
|
|
117
104
|
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
The best way to reach us is via the
|
|
106
|
+
[GitHub issues](https://github.com/jeertmans/DiffeRT/issues?q=is%3Aissue).
|
|
107
|
+
If your problem is not covered by an already existing (closed or open) issue,
|
|
108
|
+
then we suggest you create a
|
|
109
|
+
[new issue](https://github.com/jeertmans/DiffeRT/issues/new/choose).
|
|
110
|
+
You can choose from a list of templates, or open a
|
|
111
|
+
[blank issue](https://github.com/jeertmans/DiffeRT/issues/new)
|
|
112
|
+
if your issue does not fit one of the proposed topics.
|
|
120
113
|
|
|
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
|
-
```
|
|
114
|
+
The more precise you are in the description of your problem, the faster we will
|
|
115
|
+
be able to help you!
|
|
146
116
|
|
|
147
|
-
|
|
117
|
+
If you rather have question than a problem,
|
|
118
|
+
then it is probably best suited to ask it in the
|
|
119
|
+
[Q&A category of the discussions](https://github.com/jeertmans/DiffeRT/discussions/categories/q-a).
|
|
148
120
|
|
|
149
|
-
|
|
121
|
+
<!-- end reporting-an-issue -->
|
|
150
122
|
|
|
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
|
-
```
|
|
123
|
+
## Contributing
|
|
176
124
|
|
|
177
|
-
|
|
125
|
+
All types of contributions are more than welcome!
|
|
178
126
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
127
|
+
Please follow the
|
|
128
|
+
[contributing guide](https://differt.readthedocs.io/latest/contributing.html)
|
|
129
|
+
for a detailed step-by-step procedure.
|
|
182
130
|
|
|
183
131
|
## Citing
|
|
184
132
|
|
|
@@ -14,9 +14,9 @@ classifiers = [
|
|
|
14
14
|
"Topic :: Scientific/Engineering",
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
|
-
"beartype>=0.
|
|
17
|
+
"beartype>=0.19.0",
|
|
18
18
|
"chex>=0.1.86",
|
|
19
|
-
"differt-core==0.0.
|
|
19
|
+
"differt-core==0.0.26",
|
|
20
20
|
"equinox>=0.11.5",
|
|
21
21
|
"filelock>=3.15.4",
|
|
22
22
|
"jax>=0.4.32",
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Special functions.
|
|
3
|
-
|
|
4
|
-
This module extends the :mod:`jax.scipy.special` module
|
|
5
|
-
by adding missing function from :mod:`scipy.special`,
|
|
6
|
-
or by extending already implemented function to the
|
|
7
|
-
complex domain.
|
|
8
|
-
|
|
9
|
-
Those new implementation are needed to keep the ability
|
|
10
|
-
of differentating code, otherwise we could just
|
|
11
|
-
call the SciPy function and wrap their output
|
|
12
|
-
with :func:`jnp.asarray<jax.numpy.asarray>`.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
1
|
import jax
|
|
16
2
|
import jax.numpy as jnp
|
|
17
3
|
from beartype import beartype as typechecker
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
__all__ = (
|
|
4
4
|
"Paths",
|
|
5
|
+
"SBRPaths",
|
|
5
6
|
"TriangleMesh",
|
|
6
7
|
"assemble_paths",
|
|
8
|
+
"cartesian_to_spherical",
|
|
7
9
|
"fibonacci_lattice",
|
|
10
|
+
"merge_cell_ids",
|
|
11
|
+
"min_distance_between_cells",
|
|
8
12
|
"normalize",
|
|
9
13
|
"orthogonal_basis",
|
|
10
14
|
"path_lengths",
|
|
@@ -13,17 +17,21 @@ __all__ = (
|
|
|
13
17
|
"rotation_matrix_along_x_axis",
|
|
14
18
|
"rotation_matrix_along_y_axis",
|
|
15
19
|
"rotation_matrix_along_z_axis",
|
|
20
|
+
"spherical_to_cartesian",
|
|
16
21
|
"triangles_contain_vertices_assuming_inside_same_plane",
|
|
22
|
+
"viewing_frustum",
|
|
17
23
|
)
|
|
18
24
|
|
|
19
|
-
from ._paths import Paths
|
|
25
|
+
from ._paths import Paths, SBRPaths, merge_cell_ids
|
|
20
26
|
from ._triangle_mesh import (
|
|
21
27
|
TriangleMesh,
|
|
22
28
|
triangles_contain_vertices_assuming_inside_same_plane,
|
|
23
29
|
)
|
|
24
30
|
from ._utils import (
|
|
25
31
|
assemble_paths,
|
|
32
|
+
cartesian_to_spherical,
|
|
26
33
|
fibonacci_lattice,
|
|
34
|
+
min_distance_between_cells,
|
|
27
35
|
normalize,
|
|
28
36
|
orthogonal_basis,
|
|
29
37
|
path_lengths,
|
|
@@ -31,4 +39,6 @@ from ._utils import (
|
|
|
31
39
|
rotation_matrix_along_x_axis,
|
|
32
40
|
rotation_matrix_along_y_axis,
|
|
33
41
|
rotation_matrix_along_z_axis,
|
|
42
|
+
spherical_to_cartesian,
|
|
43
|
+
viewing_frustum,
|
|
34
44
|
)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"""Ray paths utilities."""
|
|
2
|
-
|
|
3
1
|
import sys
|
|
2
|
+
import warnings
|
|
4
3
|
from collections.abc import Callable, Iterator
|
|
4
|
+
from dataclasses import KW_ONLY
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
import equinox as eqx
|
|
8
8
|
import jax
|
|
9
9
|
import jax.numpy as jnp
|
|
10
10
|
from beartype import beartype as typechecker
|
|
11
|
-
from jaxtyping import Array, ArrayLike, Bool, Float, Int, Shaped, jaxtyped
|
|
11
|
+
from jaxtyping import Array, ArrayLike, Bool, Float, Int, Num, Shaped, jaxtyped
|
|
12
12
|
|
|
13
|
-
from differt.plotting import PlotOutput, draw_paths
|
|
13
|
+
from differt.plotting import PlotOutput, draw_paths, reuse
|
|
14
14
|
|
|
15
|
-
if sys.version_info >= (3, 11):
|
|
15
|
+
if sys.version_info >= (3, 11): # pragma: no cover
|
|
16
16
|
from typing import Self
|
|
17
17
|
else:
|
|
18
18
|
from typing_extensions import Self
|
|
@@ -20,7 +20,9 @@ else:
|
|
|
20
20
|
|
|
21
21
|
@jax.jit
|
|
22
22
|
@jaxtyped(typechecker=typechecker)
|
|
23
|
-
def _cell_ids(
|
|
23
|
+
def _cell_ids(
|
|
24
|
+
array: Shaped[Array, "batch n"],
|
|
25
|
+
) -> Int[Array, " batch"]: # pragram: no cover
|
|
24
26
|
@jaxtyped(typechecker=typechecker)
|
|
25
27
|
def scan_fun(
|
|
26
28
|
indices: Int[Array, " batch"],
|
|
@@ -55,6 +57,8 @@ def merge_cell_ids(
|
|
|
55
57
|
arrays. Of course, this method handles multiple dimensions
|
|
56
58
|
and will reshape the output array to match initial shape.
|
|
57
59
|
|
|
60
|
+
For an actual application example, see :ref:`multipath_lifetime_map`.
|
|
61
|
+
|
|
58
62
|
Warning:
|
|
59
63
|
The indices used in the returned array have nothing to
|
|
60
64
|
do with the ones used in individual arrays.
|
|
@@ -130,6 +134,12 @@ class Paths(eqx.Module):
|
|
|
130
134
|
"""The length (i.e., number of vertices) of each individual path."""
|
|
131
135
|
return self.objects.shape[-1]
|
|
132
136
|
|
|
137
|
+
@property
|
|
138
|
+
@jaxtyped(typechecker=typechecker)
|
|
139
|
+
def order(self) -> int:
|
|
140
|
+
"""The length (i.e., number of vertices) of each individual path, excluding start and end vertices."""
|
|
141
|
+
return self.objects.shape[-1] - 2
|
|
142
|
+
|
|
133
143
|
@property
|
|
134
144
|
@jax.jit
|
|
135
145
|
@jaxtyped(typechecker=typechecker)
|
|
@@ -297,9 +307,9 @@ class Paths(eqx.Module):
|
|
|
297
307
|
@eqx.filter_jit
|
|
298
308
|
@jaxtyped(typechecker=typechecker)
|
|
299
309
|
def reduce(
|
|
300
|
-
self, fun: Callable[[
|
|
301
|
-
) ->
|
|
302
|
-
"""Apply a function on all
|
|
310
|
+
self, fun: Callable[[Num[Array, "*batch path_length 3"]], Num[Array, " *batch"]]
|
|
311
|
+
) -> Num[Array, " "]:
|
|
312
|
+
"""Apply a function on all path vertices and accumulate the result into a scalar value.
|
|
303
313
|
|
|
304
314
|
Args:
|
|
305
315
|
fun: The function to be called on all path vertices.
|
|
@@ -322,3 +332,87 @@ class Paths(eqx.Module):
|
|
|
322
332
|
The resulting plot output.
|
|
323
333
|
"""
|
|
324
334
|
return draw_paths(self.masked_vertices, **kwargs)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@jaxtyped(typechecker=typechecker)
|
|
338
|
+
class SBRPaths(Paths):
|
|
339
|
+
"""
|
|
340
|
+
Paths method generated with shooting-and-bouncing method.
|
|
341
|
+
|
|
342
|
+
Like :class:`Paths`, but holds information of lower-order
|
|
343
|
+
paths too.
|
|
344
|
+
|
|
345
|
+
E.g., second-order paths also contain information for line-of-sight (``order = 0``)
|
|
346
|
+
and first-order paths.
|
|
347
|
+
|
|
348
|
+
Warning:
|
|
349
|
+
The ``mask`` argument is ignored as it will automatically
|
|
350
|
+
by overwritten with the last array in :attr:`masks`.
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
_: KW_ONLY
|
|
354
|
+
masks: Bool[Array, " *batch path_length-1"] = eqx.field(converter=jnp.asarray)
|
|
355
|
+
"""An array of masks.
|
|
356
|
+
|
|
357
|
+
Extends :attr:`mask`, with one mask for each path order.
|
|
358
|
+
"""
|
|
359
|
+
|
|
360
|
+
def __post_init__(self) -> None:
|
|
361
|
+
if self.mask is not None:
|
|
362
|
+
msg = (
|
|
363
|
+
"Setting 'mask' argument is ignored for this class, "
|
|
364
|
+
"as it is overwritten by 'masks' argument."
|
|
365
|
+
)
|
|
366
|
+
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
367
|
+
|
|
368
|
+
self.mask = self.masks[..., -1]
|
|
369
|
+
|
|
370
|
+
def get_paths(self, order: int) -> Paths:
|
|
371
|
+
"""
|
|
372
|
+
Return the :class:`Paths` class instance corresponding to the given path order.
|
|
373
|
+
|
|
374
|
+
Args:
|
|
375
|
+
order: The order of the path to index.
|
|
376
|
+
|
|
377
|
+
Returns:
|
|
378
|
+
The corresponding paths class.
|
|
379
|
+
|
|
380
|
+
Raises:
|
|
381
|
+
ValueError: If the provided order is out-of-bounds.
|
|
382
|
+
"""
|
|
383
|
+
if order < 0 or order > self.order:
|
|
384
|
+
msg = (
|
|
385
|
+
f"Paths order must be strictly between 0 and {self.order} (incl.), "
|
|
386
|
+
f"but you provided {order}."
|
|
387
|
+
)
|
|
388
|
+
raise ValueError(msg)
|
|
389
|
+
|
|
390
|
+
vertices = jnp.concatenate(
|
|
391
|
+
(self.vertices[..., : order + 1, :], self.vertices[..., -1:, :]),
|
|
392
|
+
axis=-2,
|
|
393
|
+
)
|
|
394
|
+
objects = jnp.concatenate(
|
|
395
|
+
(self.objects[..., : order + 1], self.objects[..., -1:]),
|
|
396
|
+
axis=-1,
|
|
397
|
+
)
|
|
398
|
+
return Paths(vertices=vertices, objects=objects, mask=self.masks[..., order])
|
|
399
|
+
|
|
400
|
+
@jaxtyped(
|
|
401
|
+
typechecker=None
|
|
402
|
+
) # typing.Self is (currently) not compatible with jaxtyping and beartype
|
|
403
|
+
def reshape(self, *batch: int) -> Self:
|
|
404
|
+
return eqx.tree_at(
|
|
405
|
+
lambda p: p.masks,
|
|
406
|
+
super().reshape(*batch),
|
|
407
|
+
self.masks.reshape(*batch, self.masks.shape[-1]),
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
def plot(self, **kwargs: Any) -> PlotOutput:
|
|
411
|
+
backend = kwargs.pop(
|
|
412
|
+
"backend", None
|
|
413
|
+
) # TODO: check if kwargs may not cause issues
|
|
414
|
+
with reuse(backend=backend) as output:
|
|
415
|
+
for order in range(self.order + 1):
|
|
416
|
+
self.get_paths(order).plot(**kwargs)
|
|
417
|
+
|
|
418
|
+
return output
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"""Mesh geometry made of triangles and utilities."""
|
|
2
1
|
# ruff: noqa: ERA001
|
|
3
2
|
|
|
4
3
|
import sys
|
|
5
|
-
from
|
|
4
|
+
from collections.abc import Iterator
|
|
5
|
+
from typing import Any, overload
|
|
6
6
|
|
|
7
7
|
import equinox as eqx
|
|
8
8
|
import jax
|
|
@@ -169,6 +169,21 @@ class TriangleMesh(eqx.Module):
|
|
|
169
169
|
is_leaf=lambda x: x is None,
|
|
170
170
|
)
|
|
171
171
|
|
|
172
|
+
def iter_objects(self) -> Iterator[Self]:
|
|
173
|
+
"""
|
|
174
|
+
Iterator over sub meshes (i.e., objects) defined by :attr:`object_bounds`.
|
|
175
|
+
|
|
176
|
+
If :attr:`object_bounds` is :data:`None`, then yield ``self``.
|
|
177
|
+
|
|
178
|
+
Yields:
|
|
179
|
+
One or more sub meshes.
|
|
180
|
+
"""
|
|
181
|
+
if self.object_bounds is None:
|
|
182
|
+
yield self
|
|
183
|
+
else:
|
|
184
|
+
for start, stop in self.object_bounds:
|
|
185
|
+
yield self[start:stop]
|
|
186
|
+
|
|
172
187
|
@property
|
|
173
188
|
def num_triangles(self) -> int:
|
|
174
189
|
"""The number of triangles."""
|
|
@@ -378,7 +393,7 @@ class TriangleMesh(eqx.Module):
|
|
|
378
393
|
vertex_b: Float[Array, "3"],
|
|
379
394
|
vertex_c: Float[Array, "3"],
|
|
380
395
|
*,
|
|
381
|
-
normal:
|
|
396
|
+
normal: None = None,
|
|
382
397
|
side_length: Float[ArrayLike, " "] = 1.0,
|
|
383
398
|
rotate: Float[ArrayLike, " "] | None = None,
|
|
384
399
|
) -> Self: ...
|
|
@@ -388,8 +403,8 @@ class TriangleMesh(eqx.Module):
|
|
|
388
403
|
def plane(
|
|
389
404
|
cls,
|
|
390
405
|
vertex_a: Float[Array, "3"],
|
|
391
|
-
vertex_b:
|
|
392
|
-
vertex_c:
|
|
406
|
+
vertex_b: None = None,
|
|
407
|
+
vertex_c: None = None,
|
|
393
408
|
*,
|
|
394
409
|
normal: Float[Array, "3"],
|
|
395
410
|
side_length: Float[ArrayLike, " "] = 1.0,
|
|
@@ -537,7 +552,10 @@ class TriangleMesh(eqx.Module):
|
|
|
537
552
|
(triangles, jnp.asarray([[0, 3, 5], [0, 5, 7]])),
|
|
538
553
|
axis=0,
|
|
539
554
|
)
|
|
540
|
-
|
|
555
|
+
|
|
556
|
+
indices = jnp.arange(0, triangles.shape[0] + 1, 2)
|
|
557
|
+
object_bounds = jnp.column_stack((indices[:-1], indices[+1:]))
|
|
558
|
+
return cls(vertices=vertices, triangles=triangles, object_bounds=object_bounds)
|
|
541
559
|
|
|
542
560
|
@property
|
|
543
561
|
def is_empty(self) -> bool:
|