An invigorating blend of 3D geometry tools in Python.
Project description
potpourri3d
A Python library of various algorithms and utilities for 3D triangle meshes and point clouds. Managed by Nicholas Sharp, with new tools added lazily as needed. Currently, mainly bindings to C++ tools from geometry-central.
pip install potpourri3d
The blend includes:
- Mesh and point cloud reading/writing to a few file formats
- Use heat methods to compute distance, parallel transport, logarithmic maps, and more
Installation
Potpourri3d is on the pypi package index with precompiled binaries for most configuations. Get it like:
pip install potpourri3d
If none of the precompiled binaries match your system, pip
will attempt to compile the library from scratch. This requires cmake
and a workng C++ compiler toolchain.
Note: Some bound functions invoke sparse linear solvers internally. The precompiled binaries use Eigen's solvers; using Suitesparse's solvers instead may significantly improve performance & robustness. To get them, locally compile the package on a machine with Suitesparse installed using the command below (relevant docs).
python -m pip install potpourri3d --no-binary potpourri3d
Documentation
Input / Output
Read/write meshes and point clouds from some common formats.
-
read_mesh(filename)
Reads a mesh from file. Returns numpy matricesV, F
, a Nx3 real numpy array of vertices and a Mx3 integer numpy array of 0-based face indices (or Mx4 for a quad mesh, etc).filename
the path to read the file from. Currently supports the same file types as geometry-central. The file type is inferred automatically from the path extension.
-
write_mesh(V, F, filename)
Write a mesh from file. Returns numpy matricesV, F
, a Vx3 real array of vertices and a Fx3 integer array of 0-based face indices (or Fx4 for a quad mesh, etc).V
a Nx3 real numpy array of verticesF
a Mx3 integer numpy array of faces, with 0-based vertex indices (or Mx4 for a quad mesh, etc).filename
the path to write the file to. Currently supports the same file types as geometry-central. The file type is inferred automatically from the path extension.
Mesh Distance
Use the heat method for geodesic distance to compute geodesic distance on surfaces. Repeated solves are fast after initial setup. Uses intrinsic triangulations internally for increased robustness.
import potpourri3d as pp3d
# = Stateful solves (much faster if computing distance many times)
solver = pp3d.MeshHeatMethodDistanceSolver(V,F)
dist = solver.compute_distance(7)
dist = solver.compute_distance_multisource([1,2,3])
# = One-off versions
dist = pp3d.compute_distance(V,F,7)
dist = pp3d.compute_distance_multisource(V,F,[1,3,4])
MeshHeatMethodDistanceSolver(self, V, F, t_coef=1., use_robust=True)
construct an instance of the solver class.V
a Nx3 real numpy array of verticesF
a Mx3 integer numpy array of faces, with 0-based vertex indices (triangle meshes only, but need not be manifold).t_coef
set the time used for short-time heat flow. Generally don't change this. If necessary, larger values may make the solution more stable at the cost of smoothing it out.use_robust
use intrinsic triangulations for increased robustness. Generaly leave this enabled.
MeshHeatMethodDistanceSolver.compute_distance(v_ind)
compute distance from a single vertex, given by zero-based index. Returns an array of distances.MeshHeatMethodDistanceSolver.compute_distance_multisource(v_ind_list)
compute distance from the nearest of a collection of vertices, given by a list of zero-based indices. Returns an array of distances.compute_distance(V, F, v_ind)
Similar to above, but one-off instead of stateful. Returns an array of distances.compute_distance_multisource(V, F, v_ind_list)
Similar to above, but one-off instead of stateful. Returns an array of distances.
Mesh Vector Heat
Use the vector heat method to compute various interpolation & vector-based quantities on meshes. Repeated solves are fast after initial setup.
import potpourri3d as pp3d
# = Stateful solves
V, F = # a Nx3 numpy array of points and Mx3 array of triangle face indices
solver = pp3d.MeshVectorHeatSolver(V,F)
# Extend the value `0.` from vertex 12 and `1.` from vertex 17. Any vertex
# geodesically closer to 12. will take the value 0., and vice versa
# (plus some slight smoothing)
ext = solver.extend_scalar([12, 17], [0.,1.])
# Get the tangent frames which are used by the solver to define tangent data
# at each vertex
basisX, basisY, basisN = solver.get_tangent_frames()
# Parallel transport a vector along the surface
# (and map it to a vector in 3D)
sourceV = 22
ext = solver.transport_tangent_vector(sourceV, [6., 6.])
ext3D = ext[:,0,np.newaxis] * basisX + ext[:,1,np.newaxis] * basisY
# Compute the logarithmic map
logmap = solver.compute_log_map(sourceV)
ps_mesh.add_parameterization_quantity("logmap", logmap)
MeshVectorHeatSolver(self, V, F, t_coef=1.)
construct an instance of the solver class.V
a Nx3 real numpy array of verticesF
a Mx3 integer numpy array of faces, with 0-based vertex indices (triangle meshes only, should be manifold).t_coef
set the time used for short-time heat flow. Generally don't change this. If necessary, larger values may make the solution more stable at the cost of smoothing it out.
MeshVectorHeatSolver.extend_scalar(v_inds, values)
nearest-geodesic-neighbor interpolate values defined at vertices. Vertices will take the value from the closest source vertex (plus some slight smoothing)v_inds
a list of source verticesvalues
a list of scalar values, one for each source vertex
MeshVectorHeatSolver.get_tangent_frames()
get the coordinate frames used to define tangent data at each vertex. Returned as a tuple of basis-X, basis-Y, and normal axes, each as an Nx3 array. May be necessary for change-of-basis into or out of tangent vector convention.MeshVectorHeatSolver.transport_tangent_vector(v_ind, vector)
parallel transports a single vector across a surfacev_ind
index of the source vertexvector
a 2D tangent vector to transport
MeshVectorHeatSolver.transport_tangent_vectors(v_inds, vectors)
parallel transports a collection of vectors across a surface, such that each vertex takes the vector from its nearest-geodesic-neighbor.v_inds
a list of source verticesvectors
a list of 2D tangent vectors, one for each source vertex
MeshVectorHeatSolver.compute_log_map(v_ind)
compute the logarithmic map centered at the given source vertexv_ind
index of the source vertex
Point Cloud Distance & Vector Heat
Use the heat method for geodesic distance and vector heat method to compute various interpolation & vector-based quantities on point clouds. Repeated solves are fast after initial setup.
import potpourri3d as pp3d
# = Stateful solves
P = # a Nx3 numpy array of points
solver = pp3d.PointCloudHeatSolver(P)
# Compute the geodesic distance to point 4
dists = solver.compute_distance(4)
# Extend the value `0.` from point 12 and `1.` from point 17. Any point
# geodesically closer to 12. will take the value 0., and vice versa
# (plus some slight smoothing)
ext = solver.extend_scalar([12, 17], [0.,1.])
# Get the tangent frames which are used by the solver to define tangent data
# at each point
basisX, basisY, basisN = solver.get_tangent_frames()
# Parallel transport a vector along the surface
# (and map it to a vector in 3D)
sourceP = 22
ext = solver.transport_tangent_vector(sourceP, [6., 6.])
ext3D = ext[:,0,np.newaxis] * basisX + ext[:,1,np.newaxis] * basisY
# Compute the logarithmic map
logmap = solver.compute_log_map(sourceP)
PointCloudHeatSolver(self, P, t_coef=1.)
construct an instance of the solver class.P
a Nx3 real numpy array of pointst_coef
set the time used for short-time heat flow. Generally don't change this. If necessary, larger values may make the solution more stable at the cost of smoothing it out.
PointCloudHeatSolver.extend_scalar(p_inds, values)
nearest-geodesic-neighbor interpolate values defined at points. Points will take the value from the closest source point (plus some slight smoothing)v_inds
a list of source pointsvalues
a list of scalar values, one for each source points
PointCloudHeatSolver.get_tangent_frames()
get the coordinate frames used to define tangent data at each point. Returned as a tuple of basis-X, basis-Y, and normal axes, each as an Nx3 array. May be necessary for change-of-basis into or out of tangent vector convention.PointCloudHeatSolver.transport_tangent_vector(p_ind, vector)
parallel transports a single vector across a surfacep_ind
index of the source pointvector
a 2D tangent vector to transport
PointCloudHeatSolver.transport_tangent_vectors(p_inds, vectors)
parallel transports a collection of vectors across a surface, such that each vertex takes the vector from its nearest-geodesic-neighbor.p_inds
a list of source pointsvectors
a list of 2D tangent vectors, one for each source point
PointCloudHeatSolver.compute_log_map(p_ind)
compute the logarithmic map centered at the given source pointp_ind
index of the source point
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for potpourri3d-0.0.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f13b23ac7e2aad0e9e3b5e9359958159e462de121b4b30072fa64a0464d358e |
|
MD5 | 7737630b2c82f83b5399114c5392415a |
|
BLAKE2b-256 | acfdc998318d6d29aefe2a061558a4e2d7a26688c804e4b38386d8140f538a50 |
Hashes for potpourri3d-0.0.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0471b8091d046dabb9567889d0add790f51af5e8b04f15d835bb71a335d645 |
|
MD5 | 5371922bc39086eac4989086b9366bca |
|
BLAKE2b-256 | ac758f9bba3186af6c9d6d0b39716e11581772d8d0bc7f1c472788eed523255d |
Hashes for potpourri3d-0.0.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 014317c5dff8d8712284d6c57692ed86f4a8094c5eda705f124b71ce54b5970c |
|
MD5 | 71a2835e821cb093c85a3ffcda1f430f |
|
BLAKE2b-256 | 8af0ddb9f173756896f8bf4f000299abc3ff8d0d2a42b8f5f6b169168bbc8308 |
Hashes for potpourri3d-0.0.1-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55b99e13f5d692b12092b949be0a515b950868af3be1a612cc9d9a3dba16f447 |
|
MD5 | 2b39e9573ffdb622471aaf2d3469b00d |
|
BLAKE2b-256 | 410ea3fc5cd5546a503eef91e152850022353e6d42d1e922436d04f242b92dd1 |
Hashes for potpourri3d-0.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6836a6753b0dd5a1881a5f7f4d8693fc32ce1fc2dd7d83f378d8d42858dd6ba |
|
MD5 | 1a1440bfa5515c38341e79bf333dee78 |
|
BLAKE2b-256 | 5b4320db4f5d3b0bc1c48594b804260767c06f604535b71f74c19646276dd2e1 |
Hashes for potpourri3d-0.0.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d8e32cd1a59fb26ffea13d7c9128ede31ad214467030c371eccde39f8aace2a |
|
MD5 | e4072b8e916907fca1a43ce41182fd1c |
|
BLAKE2b-256 | 4cf955171c7080a1b6dbb7ca8cc62e70a00e59fa7bf022f10edaddb509ad6411 |
Hashes for potpourri3d-0.0.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4697b5ad8ced925ab1fa432eb02205f4b1982628d932848ad932831c297933b9 |
|
MD5 | d2ab1408dd1ff32d7d68fc2d8ec23387 |
|
BLAKE2b-256 | bffc34d06717237187c2f8bae68c47558b744947e39d22050a5875a060b0b03d |
Hashes for potpourri3d-0.0.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd638051ea9ebb5497e45d6bc929965897f49f88307df7feb1a32a2daef941c8 |
|
MD5 | 67097071d638da87969a02e7b75d25c4 |
|
BLAKE2b-256 | 621573bc49fb890fbc02f6299fb08d5e60ae6da5a8b0ef6df3df08955706aedb |
Hashes for potpourri3d-0.0.1-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b46d4db5d0765cdf8f9eb35cf91733ce5f07e8a5e09b87257e9efec06f417c |
|
MD5 | 89a549b3c1840cd85f50eae93cf340e4 |
|
BLAKE2b-256 | c996655304260cb167401a68ab977bafa942ae3f750ee4bda2961dd423126294 |
Hashes for potpourri3d-0.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e36a5a8f486b6bc91e95096e20097b5d72e378e570d28bf91c5a8d77eab33e7 |
|
MD5 | 5eeb164e42320658bca46a09bb2a260a |
|
BLAKE2b-256 | 2e978b99bf33ab9576d04cdce0db7cb526731468c9b5018f02d2a8f4876f22a1 |
Hashes for potpourri3d-0.0.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68014d6b722a63165228fad833b9d2f05b57e3d5a6d057a09ffb4e1be5fdb01b |
|
MD5 | e0d98c0d916559480d95c0871d589aec |
|
BLAKE2b-256 | e11a89ac0d16c8b99b4b4ae1f3fbfb1020e4c8abcadb20eaa17455d68fc038c6 |
Hashes for potpourri3d-0.0.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 247ff573e9f8532f23f8e29981b7de1aa606835d141486bfcbc6219c500221bd |
|
MD5 | 20a150193706bec18d5648125e8781ae |
|
BLAKE2b-256 | 1eaac5f2739ef9f50482f1ead2f20aa7ef6e4d3b8d06645e64395d4a4601c5a5 |
Hashes for potpourri3d-0.0.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2566f1890afa2f3898ef8d15f7c48418860386df1bd7afb0c6988695614f3902 |
|
MD5 | 8503d8dcc53c5ea32bd8a7d0931da9dc |
|
BLAKE2b-256 | b24fc7804b7b822996e3f82a31d147a1864defc55ef4f58fb78cfc05e81863cf |
Hashes for potpourri3d-0.0.1-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fcc1141346f6508b72db770292451369db428c367f4a68996b426006bceeee3 |
|
MD5 | 27c40ca8ea3c6e21187482792c983e8f |
|
BLAKE2b-256 | 287f60c5e766ed5f9b4caa4839f368c113e53f3029735a3c107b27f1ca673d31 |
Hashes for potpourri3d-0.0.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd841c487546ef7ab4986e49d2cc47b2266c784836f3968fdc441b4cb8b6763 |
|
MD5 | af14eb5d8ccdcbd37a4a1407cc7cabbe |
|
BLAKE2b-256 | 21e8431d654915dbc0eccc1ee323a8ac67809a1e0e76d42bdf59193bada30ae9 |
Hashes for potpourri3d-0.0.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b95fd32ddf7a2e96eda764d75d3a8f26e5712bb6aa1fc533cb81924d4a37acd9 |
|
MD5 | f0b76ed3a56562cc57db562a1a83a04e |
|
BLAKE2b-256 | 5a70b79751de8057345cb2056631e67986797447460a44d06944eb6f42f55e72 |
Hashes for potpourri3d-0.0.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9498d8088981cf2e04d177c4d141dd14be1fc81755257d12f80a59832260b8c |
|
MD5 | 92568d4f2aa3a2e4888a9df5f7b7e565 |
|
BLAKE2b-256 | d36d56a29fb6710207f8072fd5fc922822e9b5b5d33393a0e902a4e99ce174d8 |
Hashes for potpourri3d-0.0.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efc15a77788993a91a0068b2e29343073abb54e34561f841c48b3d873ffd3d80 |
|
MD5 | cf75271e3e2916cf1f0b99746785ece8 |
|
BLAKE2b-256 | 2eda2647da416f53257ec7aad7b8d3765178cf47cf7129ddb41543c8b98afb7b |
Hashes for potpourri3d-0.0.1-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eff7c95c6a99a358c588c9c0e08e95a4c9e2e1ab416eeec007ee8ed98d84ea60 |
|
MD5 | 8d92691c74ad93abb4fb6fb765308c3a |
|
BLAKE2b-256 | 052a9b4ff5a8a0df7c55c58fa0eaad6f8ef47940109b1ed94f2e4b8ad3f12bd6 |
Hashes for potpourri3d-0.0.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45f3413c2c606ed41b931f0f3f6426365e26f416e97f7a2e11f5541fcbaf6f56 |
|
MD5 | 804451a27077e3575ed1b0673e6f5517 |
|
BLAKE2b-256 | 2eef20dfd7ff83a15f7463eb0ab3e568c2bcfad96abaeba12801c91f8bec129d |
Hashes for potpourri3d-0.0.1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5c750f81a6314ce361fce74ab6ab5928a96812127fe37162100ceafd4f688a6 |
|
MD5 | d8244a572ad65ea5aa5f66f246bdb313 |
|
BLAKE2b-256 | 4fe5f4be4e5de85e763c2affc9b2f01e7f38ed2db3cd841eb23846c4e008e273 |
Hashes for potpourri3d-0.0.1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 761e61c733ef98e3bd1aebb3ad35d970d3d9e80c29f48290da7e7bb7d6633413 |
|
MD5 | a578e64fcf6d0fc4aa67e053b0795c80 |
|
BLAKE2b-256 | ca73cb30aec3c3dd6ff35e38a2e2c5872d837499e1e10cd1adc05c1885abd90b |
Hashes for potpourri3d-0.0.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f782ae33bec8a538155401e0d6b2461a1d77799b0e78d1811a02efb2f6229c20 |
|
MD5 | d44b1d4f0573c6c16cf4947f2a971fa8 |
|
BLAKE2b-256 | cce11ff5efde95ee4d83a14a509a6d080f47ca3f3996318660bf978e43179bf4 |
Hashes for potpourri3d-0.0.1-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4b5592fec2ffad15aba9580b8dedddc042380dd2db33cdf6c13061bdd9bc856 |
|
MD5 | 2b1856bfce593624ef9de6dba9d05ff6 |
|
BLAKE2b-256 | b445bcebc1b8198f9db64bc081c6f84046636323336f02a7ec59c823f41806a2 |
Hashes for potpourri3d-0.0.1-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86be92bd3af1e5d4af175a915c1390419c0d160df46a0f0f5c19b0c715eca2d6 |
|
MD5 | 268399c7a8e22ed5baae94fece2cd18a |
|
BLAKE2b-256 | 0ce122987205fafaa530ead278ceae2fec9c83a0b99d6b7117aa95d1ef938084 |
Hashes for potpourri3d-0.0.1-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cec1b685c3ce4718f005b11104c4ff0f442f54413a932561f318ab214f3cf9c |
|
MD5 | 2ef1f6aa19652a687eaa665ec8cbdd8a |
|
BLAKE2b-256 | cfdcffc0a960519660722762a0bf776126e3fe7081fb394752c1d51d401cca73 |
Hashes for potpourri3d-0.0.1-cp27-cp27mu-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05cc4b13dafd509d43bd7ed8adf16c5de2bc1e734e9b1f9c970d2dca3919ea42 |
|
MD5 | 973db8d51c0347a79f65a7eb8464e17f |
|
BLAKE2b-256 | 5dfe683fba1a07832bb2e5616abf3ea9c392c420cddf5b41a4de8c21ee67c1a2 |
Hashes for potpourri3d-0.0.1-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f26212ead5a52f9bcf1cda8e1be875d1cda6329c74488efcc2e8d048195168a |
|
MD5 | 797de6eca9a035edb4d59f853b4c54df |
|
BLAKE2b-256 | 422afb9d1d8f3e818839537c997853c913226500086e403ea3739ec04dde0da4 |
Hashes for potpourri3d-0.0.1-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 112fc7e657f2b8cce030d7044b715bb29f31a8177b2b6b1856dddb8c515a2fe5 |
|
MD5 | d3f2e6a0910e8691f6af3b9faa654437 |
|
BLAKE2b-256 | 5699dbc2f69881b0563b45d6b343bdcea17c1ab87f6b773e9b007469518c4492 |
Hashes for potpourri3d-0.0.1-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0478a649bf89cc34872bc91387f64122a5de92248952a102391502f4d36d810e |
|
MD5 | a9ce7dd9b44d03328e2a565248403584 |
|
BLAKE2b-256 | b655bf4a5f16d5a172714786224b46f55bdc3fd5db601b420c776c9005f5cebe |
Hashes for potpourri3d-0.0.1-cp27-cp27m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85431fa074d479a5c8acbfe460f5eb9340a55547fa0378071031a2de42f4cc52 |
|
MD5 | 2fb0b2d02ba05901d59c9773d8d28ad1 |
|
BLAKE2b-256 | 0bce969b09ce42da58a6366d9bff4adb1d9951564f2c9881337015d60e9a29f5 |
Hashes for potpourri3d-0.0.1-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25767200f55fe69a566eb0b40a5cf8505735cf865b04ac60bd6e795b17465aa8 |
|
MD5 | df8f130f4579e9be2c099924b6663f88 |
|
BLAKE2b-256 | 2d538cdf68d3b9d92984acab8efe4ff58430d571d7955c4022d31a4932884fd0 |