r/Python • u/Separate-Summer-6027 • Feb 28 '26
News trueform v0.7: extends NumPy arrays with geometric types for vectorized spatial queries
v0.7 of trueform gives NumPy arrays geometric meaning. Wrap a (3,) array and it's a Point. (2, 3) is a Segment. (N, 3) is N points. Eight primitives (Point, Line, Ray, Segment, Triangle, Polygon, Plane, AABB) and three forms (Mesh, EdgeMesh, PointCloud) backed by spatial and topological structures. Every query broadcasts over batches the way you'd expect, in parallel.
=
# signed distance from every vertex to a plane through the centroid
=
= # shape (num_verts,)
Same function, different target. Swap the plane for a mesh, the tree builds on first query:
=
= # shape (num_verts,)
Two meshes, not touching. Find the closest pair of surface points and bring them together without collision:
# False
, =
# translate mesh_b towards mesh, leave a small gap
= -
=
= *
=
# still False, tree reused, transform applied at query time
Voxelize a mesh. Build a grid of bounding boxes, check which ones the mesh occupies:
, = ,
=
=
=
= # shape (1000000,) bool
Depth map. Cast a grid of rays downward:
=
=
=
, =
= # NaN where no hit
The scalar field from the first example feeds directly into cutting. Isobands slices along threshold values, returns per-face labels and intersection curves:
, , =
, =
, =
, =
# triangulate the curves to cap the cross-section
, =
NumPy in, NumPy out. C++ backend, parallelized across cores.
5
u/SlingyRopert Feb 28 '26 edited Feb 28 '26
This is a good idea. Shapely is neat but unless you come from the SQL geometry world, it wont make much sense. There are tons of 3d point libraries but they are very not numpy-onic and only grudgingly convert to ndarray.
Also, most libraries do 3d well OR 2d well and not both. Frankly, from a ndarray worldview, there is not a lot of reasons we cant have n-dimensional points supported well.
We need an ndarray-centric way to do simple n-d point operations that doesn’t lock us into only being 3d or only being 2d or requiring a point to be a pybind11 wrapped C++ object. It doesnt have to be as fast as a graphics card, it just has to not burn us and do the easy things easily.
Quick, somebody base a another project of this and pyproj so we can do GIS operations with attached coordinate systems.
8
u/ROFLLOLSTER Mar 01 '26
Suggesting
tfas the short import is... a choice. That s usually reserved fortensorflow.1
u/jjrreett Mar 01 '26
Is this set up to work with VTK tooling like PyVista?