Share spatial clipping and height slices across live planning and recorded observations. Refine scene navigation, report serialization and viewer presentation.
19 lines
747 B
Python
19 lines
747 B
Python
"""View-only height bands; never mutate source geometry or tracking inputs."""
|
|
import math
|
|
import numpy as np
|
|
|
|
|
|
def height_mask(points, floor_m=None, ceiling_m=None):
|
|
if any(v is not None and not math.isfinite(v) for v in (floor_m, ceiling_m)):
|
|
raise ValueError("Height bounds must be finite")
|
|
if floor_m is not None and ceiling_m is not None and floor_m > ceiling_m:
|
|
raise ValueError("Lower height exceeds upper height")
|
|
mask = np.ones(len(points), dtype=bool)
|
|
if floor_m is not None or ceiling_m is not None:
|
|
mask &= np.isfinite(points).all(axis=1)
|
|
if floor_m is not None:
|
|
mask &= points[:, 2] >= floor_m
|
|
if ceiling_m is not None:
|
|
mask &= points[:, 2] <= ceiling_m
|
|
return mask
|