How to calculate an irregular shape area?

6 ビュー (過去 30 日間)
Wenlong
Wenlong 2012 年 6 月 22 日
編集済み: Karan Singh 2025 年 1 月 31 日
Dear all,
I have a shape model in 3D space. I project it onto a 2D plane. Now I have to calculate the area of its projection area. Since the area is irregular, how can I calculate it? Is there any method in matlab can help me to make it?
Many thanks for your help.
Best wishes Wenlong
  3 件のコメント
Izaro
Izaro 2019 年 5 月 24 日
移動済み: DGM 2024 年 12 月 12 日
I have the same problem. How do you solve it?
Thanks
Mathieu NOE
Mathieu NOE 2024 年 12 月 13 日
hello
as suggested by @Walter Roberson polyarea does the job even for irregular or concave shapes

サインインしてコメントする。

回答 (1 件)

Karan Singh
Karan Singh 2025 年 1 月 31 日
編集済み: Karan Singh 2025 年 1 月 31 日
Hi Wenlong and Izaro,
The answer is already covered in the comments above; however, I can assume that you might be working with different types of projections. A few come to mind:
  • If your projection is a scattered set of plots, you can use "alphaShape" to create a boundary and then compute the area. alphaShape
  • If it is a single polygon, you can use "boundary" and then "polyarea." polyarea
  • If it contains holes, use "polyshape" and "rmholes" to remove holes and get the area. Maybe useful depends on cases.
[x, y, z] = sphere(50);
vertices_3d = [x(:), y(:), z(:)];
vertices_2d = vertices_3d(:, 1:2); % projection
shp = alphaShape(vertices_2d, 1); %alphaShape
Warning: Duplicate data points have been detected and removed.
area_alpha = area(shp);
k = boundary(vertices_2d(:,1), vertices_2d(:,2), 0.8); % polyarea
boundary_vertices = vertices_2d(k, :);
area_poly = polyarea(boundary_vertices(:,1), boundary_vertices(:,2));
fprintf('Area via alphaShape: %.4f\n', area_alpha);
Area via alphaShape: 3.1333
fprintf('Area via boundary: %.4f\n', area_poly);
Area via boundary: 3.1333

カテゴリ

Help Center および File ExchangeBounding Regions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by