Use the adjacency_matrix module
mainadjacency_matrix module in gpytoolbox provides tools for working with adjacency matrices in geometry processing. This module is part of the src.gpytoolbox.adjacency_matrix namespace.repository·main·Indexed 42 days ago
https://github.com/sgsellan/gpytoolboxA Python-based geometry processing toolbox providing research utility functions for geometry processing tasks. Compatible with Python 3.10 through 3.13, it includes tools for mesh decimation, cotangent Laplacian computation, biharmonic energy calculation, and winding number computation. The library uses a dual-licensing model, with the main module under the MIT license and the gpytoolbox.copyleft module under the GPL license.
adjacency_matrix module in gpytoolbox provides tools for working with adjacency matrices in geometry processing. This module is part of the src.gpytoolbox.adjacency_matrix namespace.upper_envelope module provides functionality to compute the upper envelope of a collection of functions. This is useful in geometry processing for determining the pointwise maximum of multiple mathematical descriptions.Gpytoolbox uses a dual-licensing model based on which modules you import:
gpytoolbox module and its individual functions. Use this for standard research and development.import gpytoolbox or from gpytoolbox import regular_square_mesh.gpytoolbox.copyleft module. If you import from this module, your code must comply with GPL terms.from gpytoolbox.copyleft import mesh_boolean.To build Gpytoolbox from a specific git commit (e.g., for development or to access features in the main branch not yet released), clone the repository and install it locally:
numpy.python -m pip install numpy
python -m pip install .Certain functionalities in Gpytoolbox use C++ bindings. These must be compiled manually if you require that specific functionality. The process is platform-dependent and requires cmake and a C++ compiler.
mkdir build
cd build
cmake ..
make -j2sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libmpfr-dev libgmp-dev
mkdir build
cd build
cmake ..
make -j2mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build "." --config ReleaseTo install the latest stable release of Gpytoolbox, use pip:
python -m pip install gpytoolboxYou can access documentation for functions in two ways:
help() function or access the __doc__ attribute.>>> from gpytoolbox import grad
>>> help(grad)The random_points_on_mesh function allows you to sample a set of points uniformly distributed across the surface of a mesh. This is useful for tasks like point cloud generation or surface analysis.
To use this function, you typically provide a mesh object (such as one from trimesh or a similar geometry processing library) and specify the number of points you wish to sample.
from gpytoolbox.random_points_on_mesh import random_points_on_mesh
# Assuming 'mesh' is a valid mesh object
points = random_points_on_mesh(mesh, num_points=1000)The decimate module provides functionality to reduce the number of faces/vertices in a mesh (decimation).
Note: The specific API details (parameters and return types) are defined in the src.gpytoolbox.decimate module. Refer to the function signatures in the source code for exact parameter names and expected mesh formats.
The squared_distance_precompute class provides a precomputed AABB (Axis-Aligned Bounding Box) tree to accelerate repeated closest-point queries. It wraps libigl's C++ igl::AABB implementation, allowing you to build the bounding volume hierarchy once and reuse it across multiple calls to squared_distance, signed_distance, or winding_number. This avoids the $O(n)$ cost of rebuilding the tree for every query.
squared_distance wrapper: Pass the precomputed tree instance to the aabb parameter of the gpytoolbox.squared_distance function..squared_distance(P) method on the tree instance itself for closest-point queries.FIf the face/edge index matrix F is not provided:
V is treated as an ordered closed polyline.V is treated as a point cloud.# Pattern 1: Passing to the wrapper
v, f = gpytoolbox.read_mesh("bunny.obj")
tree = gpytoolbox.squared_distance_precompute(v, f)
for _ in range(num_iters):
P = 2*np.random.rand(num_samples,3)-4
sqrD, I, lmbs = gpytoolbox.squared_distance(P, v, F=f, use_cpp=True, aabb=tree)
# Pattern 2: Direct query
tree = gpytoolbox.squared_distance_precompute(v, f)
sqrD, I, C = tree.squared_distance(P)The AABB tree is constructed by identifying the dimension with the largest spread (difference between max and min coordinates) and splitting the elements into two groups based on the median value along that axis.
This process continues recursively until each leaf node contains only one element (or a single triangle/simplex). The tree structure allows for fast spatial lookups by traversing the hierarchy of bounding boxes.
The gaussian_process_precompute class implements two main modes of operation depending on whether inducing points are provided:
X_induced): Uses a set of inducing points to approximate the GP. This reduces complexity, making it suitable for larger datasets. It computes a matrix $\Sigma_{inv}$ involving the inducing points and the training points to perform the approximation.Both modes support using observed gradients (grad_y_train) and compact kernel support to optimize computation.