7
$\begingroup$

I have a 2D surface in 3D (it's a cut) given in data points of the form (x,y,z):

data = ToExpression@Import["http://pastebin.com/raw/6ufm8bx3", "String"];

What is the easiest way to calculate area between the points?

ListPointPlot3D[data]

ListPlot3D?

$\endgroup$
16
$\begingroup$

Assuming you want the area of the polygon made of the points.

At first we'll order the points:

orderedPoints=points[[FindShortestTour[points][[2]]]];

Then lets look at what we have made with Polygon:

Show[ListPointPlot3D[points],Graphics3D[{Opacity[0.5],Polygon[orderedPoints]}]]

Our plot with the code above

Then we use the built-in Area function:

Area[Polygon[orderedPoints]]

0.000428182

$\endgroup$
6
$\begingroup$

this projects the points onto a plane and then computes the area of the 2d figure:

This is especially useful in case you already know the plane, but for this example we get the plane from a least squares fit.

mean = Mean[p];
cp = {x0, y0, z0};
{cp, n2} = {{x0, y0, z0}, {ny, nz }} /.
    FindMinimum[
     Total[Dot[ # - cp , {1, ny, nz } ]^2 & /@ p],
       {{x0, mean[[1]]}, {y0, mean[[2]]}, {z0, mean[[3]]}, ny, nz}][[2]]
n = Normalize[Prepend[n2, 1]];
v1 = Normalize[p[[1]] - cp - (p[[1]] - cp).n n];
v2 = Cross[v1, n];
p2d = {v1.#, v2.#} & /@ ((# - cp) & /@ p);
Graphics[Point[p2d]]

enter image description here

Abs@Total[Det /@ Partition[p2d[[FindShortestTour[p2d][[2]]]], 2, 1, 1]]/2

0.000426947

see here for the area calculation: https://mathematica.stackexchange.com/a/22587/2079

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.