52 views (last 30 days)

Show older comments

I have 3 vectors "xcoord", "ycoord", and "zcoord" that represent the (x,y,z)-coordinates of a 2D surface in 3D space. I want to determine the surface area of the surface.

I tried using the "surfaceArea" method for an "AlphaShape" object, but the surface was disconnected. On changing the "Alpha" value, the 2D surface became a 3D object.

I want to compute the surface area for the connected 2D surface. How can I do this?

MathWorks Support Team
on 10 Jul 2017

If you want to compute the surface area of a 2-D surface in a 3-D space, the Delaunay Triangulation would be the best approach to go ahead with. You could compute the sum of the triangles formed by the Delaunay Triangulation to find the surface area of the 2-D surface.

The following steps should help to obtain a 'delaunay' surface and to compute the surface area of the same.

1) tri = delaunay(X,Y) creates a 2-D Delaunay triangulation. 'tri' is a matrix representing the set of triangles that make up the triangulation.

tri = delaunay(xcoord,zcoord);

P = [xcoord,ycoord,zcoord];

2) Obtain the edges in each triangle formed by the 'delaunaytriangulation'

v1 = P(tri(:,2), :) - P(tri(:,1), :);

v2 = P(tri(:,3), :) - P(tri(:,2), :);

3) Calculating the cross product of the edges in each triangle of the surface

cp = 0.5*cross(v1,v2);

4) Surface area of the entire surface is calculated as the sum of the areas of the individual triangles

surfaceArea = sum(sqrt(dot(cp, cp, 2)))

Prakash Raut
on 30 Jan 2020

Hi, I was wondering why xcoord and zcoord was used for traingulation , but not ycoord?

Jerry Campbell
on 28 Oct 2020

I created a simple Cube with sides of 100mm in AutoCad then exported the STL file

I then used the following code to calculate the volume and surface area of the cube.

% Create PDE Model

UnitCubeModel = createpde();

% Import STL file into Geometry of Model

UnitCubeModelGeometry = importGeometry(UnitCubeModel,'Unit Cube 100mm v1.stl');

% Generate Mesh for Model

UnitCubeMesh = generateMesh(UnitCubeModel);

% V for vertices and F for the facets

% allDisplayFaces is backward compatible method of the Geometry Object

[F, V] = UnitCubeModelGeometry.allDisplayFaces();

% Perform cross product across all the Facets and Vertices in the Model

a = V(F(:, 2), :) - V(F(:, 1), :);

b = V(F(:, 3), :) - V(F(:, 1), :);

c = cross(a, b, 2);

% Calculate Surface Area and Volume of Model

modelSurfaceArea = 1/2 * sum(sqrt(sum(c.^2, 2)));

modelVolume = volume(UnitCubeMesh);

% Plot the PDE Model

pdegplot(UnitCubeModel,'FaceLabels','on','FaceAlpha',0.5);

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!