user668074
user668074

Reputation: 1141

2d integration over non-uniform grid

I'm writing a data analysis program and part of it requires finding the volume of a shape. The shape information comes in the form of a lost of points, giving the radius and the angular coordinates of the point.

If the data points were uniformly distributed in coordinate space I would be able to perform the integral, but unfortunately the data points are basically randomly distributed.

My inefficient approach would be to find the nearest neighbours to each point and stitch the shape together like that, finding the volume of the stitched together parts.

Does anyone have a better approach to take?

Thanks.

Upvotes: 1

Views: 923

Answers (3)

Nico Schlömer
Nico Schlömer

Reputation: 58861

Sounds like you want the convex hull of a point cloud. Fortunately, there are efficient ways of getting you there. Check out scipy.spatial.ConvexHull.

Upvotes: 0

Michael
Michael

Reputation: 5939

Ok, here it is, along duffymo's lines I think.

First, triangulate the surface, and make sure you have consistent orientation of the triangles. Meaning that orientation of neighbouring triangle is such that the common edge is traversed in opposite directions.

Second, for each triangle ABC compute this expression: H*cross2D(B-A,C-A), where cross2D computes cross product using coordinates X and Y only, ignoring the Z coordinates, and H is the Z-coordinate of any convenient point in the triangle (although the barycentre would improve precision).

Third, sum up all the above expressions. The result would be the signed volume inside the surface (plus or minus depending on the choice of orientation).

Upvotes: 0

duffymo
duffymo

Reputation: 308948

IF those are surface points, one good way to do it would be to discretize the surface as triangles and convert the volume integral to a surface integral using Green's Theorem. Then you can use simple Gauss quadrature over the triangles.

Upvotes: 2

Related Questions