trimesh.integrate module

integrate.py

Utilities for integrating functions over meshes surfaces.

Functions

substitute_barycentric(function)

symbolic_barycentric(function)

Symbolically integrate a function(x,y,z) across a triangle or mesh.

trimesh.integrate.substitute_barycentric(function)
trimesh.integrate.symbolic_barycentric(function)

Symbolically integrate a function(x,y,z) across a triangle or mesh.

Parameters

function (string or sympy expression) – x, y, z will be replaced with a barycentric representation and the the function is integrated across the triangle.

Returns

  • evaluator (numpy lambda function of result which takes a mesh)

  • expr (sympy expression of result)

Examples

In [1]: function = ‘1’

In [2]: integrator, expr = integrate_barycentric(function)

In [3]: integrator Out[3]: <__main__.evaluator instance at 0x7f66cd2a6200>

In [4]: expr Out[4]: 1/2

In [5]: result = integrator(mesh)

In [6]: mesh.area Out[6]: 34.641016151377542

In [7]: result.sum() Out[7]: 34.641016151377542