find area of 3D polygon

3.8k views Asked by At

Given a matrix nx3 that represents n points in 3D space. All points lie on a plane. The plane is given by its normal and a point lying on it. Is there a Matlab function or any Matlabby way to find the area directly from the matrix?

What i was trying to do is write a function that first computes the centroid,c, of the n-gon. Then form triangles : (1,2,c),(2,3,c),...,(n,1,c). Compute their area and sum up. But then i had to organise the polygon points in a cyclic order as they were unordered which i figured was hard. Is there a easy way to do so?

Is there a easier way in Matlab to just call some function on the matrix?

3

There are 3 answers

0
Joseph O'Rourke On BEST ANSWER

Here is perhaps an easier method. First suppose that your plane is not parallel to the z-axis. Then project the polygon down to the xy-plane simply by removing the 3rd coordinate. Now compute the area A' in the xy-plane by the usual techniques.

If your plane makes an angle θ with the xy-plane, then your 3D area A = A' / cos θ.

If your plane is parallel to the z-axis, do the same computation w.r.t. the y-axis instead, projecting to the xz-plane.

1
AudioBubble On

To project from 3D to the plane normal to N, take some non-parallel vector A and compute the cross products U = N x A and V = N x U. After normalizing U and V, the dot products P.U and P.V give you 2D coordinates in the plane.

Joseph's solution is even easier (I'd recommend to drop the coordinate with the smallest absolute cosine).

3
paisanco On

You said the points all lie on a plane and you have the normal. You should then be able to reproject the 3-D points into 2-D coordinates in a new 2-D basis. I am not aware of a canned function in Matlab to do this , but coding it should not be difficult, this answer from Math.SE and this Matlab Central post should help you.

If you already solved the problem of finding the coordinates of the points in the 2-D plane they are in, you could use the Matlab boundary or convex hull function to compute the area of the boundary or convex hull enclosing the points.

[k,v]= boundary(x,y)

or

[k,v] =convhull(x,y)

where k is the vector of indices into points x,y, that define the boundary or convex hull, v is the area enclosed, and x, y are vectors of the x and y coordinates of your points.

What you were describing with trying to find triangles with the points sounds like a first attempt toward Delaunay triangulation. I think more recent versions of Matlab have functions to do Delaunay triangulation as well.