Skip to content

Commit

Permalink
Fix distribute_points() for non-unit cells
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Dec 20, 2023
1 parent dddebb4 commit 190c35e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions phi/field/_point_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def distribute_points(geometries: Union[tuple, list, Geometry, float],
center: bool = False,
radius: float = None,
extrapolation: float or Extrapolation = math.NAN,
bounds: Box = None,
**domain) -> Field:
"""
Transforms `Geometry` objects into a PointCloud.
Expand All @@ -77,17 +78,18 @@ def distribute_points(geometries: Union[tuple, list, Geometry, float],
center: Set all points to the center of the grid cells.
radius: Sphere radius.
extrapolation: Extrapolation for the `PointCloud`, default `NaN` used for FLIP.
bounds: Grid bounds. Specify grid resolution via `**domain`.
Returns:
PointCloud representation of `geometries`.
"""
warnings.warn("distribute_points() is deprecated. Construct a PointCloud directly.", DeprecationWarning)
from phi.field import CenteredGrid
if isinstance(geometries, (tuple, list, Geometry)):
from phi.geom import union
geometries = union(geometries)
geometries = resample(geometries, CenteredGrid(0, extrapolation, **domain), scatter=False)
geometries = resample(geometries, CenteredGrid(0, extrapolation, bounds=bounds, **domain), scatter=False)
initial_points = _distribute_points(geometries.values, dim, points_per_cell, center=center)
initial_points = geometries.bounds.local_to_global(initial_points / geometries.resolution)
if radius is None:
from phi.field._field_math import data_bounds
radius = math.mean(data_bounds(initial_points).size) * 0.005
Expand Down

0 comments on commit 190c35e

Please sign in to comment.