Three-dimensional model surface area calculation method

[Copyright Statement]
This article is an original article by the blogger. Reproduction without the permission of the blogger is strictly prohibited. We will conduct infringement searches regularly.

For more algorithm summaries, please follow my blog: https://blog.csdn.net/suiyingy, or the "Lele Perception School" official account.
This article comes from the series of articles in the column "Python 3D Model Processing Basics". The column address is: https://blog.csdn.net/suiyingy/category_12462636.html.  

        In today’s digital era, three-dimensional models have been widely used in various fields, such as game development, architectural design, engineering drawing, etc. Understanding the surface area of ​​a three-dimensional model and its calculation method is of great significance for the geometric feature analysis and subsequent processing of the model. This blog post will give you an in-depth understanding of the definition, role and calculation method of surface area of ​​3D models.

1 Surface area definition

        The surface area of ​​a three-dimensional model refers to the total area of ​​all external surfaces of the model. Mathematically, it can be viewed as a combination of polygonal meshes, consisting of many planar triangles. Each triangle has its own area, and adding them together gives you the surface area of ​​the entire model.

2 Surface area effect

        Geometric feature analysis: Surface area can be used to analyze and describe the geometric features of a three-dimensional model. Through the surface area, we can understand the size, shape and level of detail of the model, thus providing basic data for subsequent evaluation and improvement work.

        Lighting and rendering: In computer graphics, lighting and rendering are important steps in simulating the real world. Surface area determines how much light each part of the model can receive, thus affecting the final visual effect. Calculating surface area helps optimize the rendering process, improving image quality and realism.

        Physical simulation: In physical simulation, surface area is very important for calculating the mass, density and collision detection of the model. By calculating the surface area, the physical behavior of the model can be simulated more accurately, improving the accuracy and realism of the simulation.

        In addition, the weight of the weighted summation in the calculation process of the three-dimensional model vertex normal vector introduced in the previous section is also determined by the surface area.

3 Calculation methods

        There are many ways to calculate the surface area of ​​a three-dimensional model. Here are two commonly used methods, namely the polygon mesh method and the surface fitting method.

        The steps of the polygon mesh method are:

        (1) First, the three-dimensional model is represented as a polygon mesh composed of multiple small triangles.

        (2) To calculate the area of ​​each triangle, you can use Heron's formula or vector operations and other methods.

        (3) Add the areas of all triangles to get the surface area of ​​the entire model.

        The steps of surface fitting method are:

        (1) First, the three-dimensional model surface is discretized into a series of point clouds.

        (2) Use surface fitting algorithms, such as Bezier curves or B-spline curves, to fit the point cloud into a smooth surface.

        (3) Calculate the surface area of ​​the fitted surface.

        It should be noted that the accuracy of calculating the surface area of ​​a three-dimensional model is related to the degree of discretization. A denser mesh or point cloud will provide more accurate results, but will also increase computational complexity and storage requirements.

4 python sample programs

        ​ ​ 4.1 Single triangular surface

        ​​​​Here we still use trimesh and open3d to calculate the surface area of ​​the three-dimensional model. Let's first take a single triangular surface as an example, assuming that the vertex coordinates are [[0.0, 0.0, 1.0], [3.0, 0.0, 1.0], [0.0, 4.0, 1.0]] respectively. Obviously, this is a right triangle with an area of ​​1/2 * 3 * 4 = 6.

        The function used by Trimesh to calculate the surface area of ​​the three-dimensional model is mesh.area. The calculation result of the above triangular surface is 6.0, which is consistent with the expected theoretical results. The key procedures are as follows.

mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
print('area result: ', mesh.area)

        The function used by Open3d to calculate the surface area of ​​a three-dimensional model is open3d.geometry.TriangleMesh.get_surface_area (Python method, in open3d.geometry.TriangleMesh). The calculation result of the above triangular surface is 6.0, which is consistent with the expected theoretical result. The key procedures are as follows.

mesh.vertices = o3d.utility.Vector3dVector(vertices)
mesh.triangles = o3d.utility.Vector3iVector(faces)
print('area result: ', mesh.get_surface_area())

        4.2 Surface area of ​​triangular prism

        Assume that the vertices of the triangular prism and the triangular mesh faces are [[0.0, 0.0, 0.0], [3.0, 0.0, 0.0], [0.0, 4.0, 0.0], [0.0, 0.0, 5.0], [3.0, 0.0, 5.0 ], [0.0, 4.0, 5.0]], [[1, 3, 2], [2, 3, 5], [5, 3, 6], [1, 4, 3], [3, 4, 6 ], [1, 2, 4], [2, 5, 4], [4, 5, 6]]. The schematic diagram of a triangular prism is as shown below. The base is a right triangle. The areas of the upper and lower bases are both 6.0, and the areas of the three sides are 15.0, 20.0, and 25.0, so the total area is 72.0.

Figure 1 Triangular prism model

        The corresponding surface area calculation results of Trimesh and open3d are both 72.0. As mentioned in the previous blog post, the volume calculation results of the three-dimensional model are affected by the vertex order and closure. The surface area of ​​the three-dimensional model is not affected by the order of vertices, and only the sum of the areas of the triangular mesh is calculated. The holes will not be automatically completed or involved in the calculation.

        ​​​​Trimesh can obtain the area of ​​each triangular face through mesh.area_faces. For example, the calculation result of area_faces corresponding to the above triangular prism is [6. 12.5 12.5 10. 10. 7.5 7.5 6.].

        The detailed Python sample program download address for the above calculation results is "https://download.csdn.net/download/suiyingy/88457956 ”, or just reply to “Basics of 3D Processing” in “Lele Perception School”.

        In addition, Cloud Compare also provides a surface area calculation method for 3D models. The calculation steps are: first load and select the mesh model, and then click Edit->Mesh->Measure surface, as shown in the figure below.

Figure 2 Could Compare surface area calculation process

        The surface area calculation result will be displayed in the prompt area below, as shown in the figure below. The calculated result of the triangular prism surface area is S=72, which is consistent with the above manual calculation result.

Figure 3 Could Compare surface area calculation results

        This blog post introduces the definition, function and commonly used calculation methods of three-dimensional model surface area. Understanding the surface area of ​​a 3D model is important for model analysis, rendering and simulation. By calculating the surface area, we can gain a deeper understanding of the geometric characteristics of the three-dimensional model and provide strong support for applications in related fields. I hope this article can help readers better understand and apply the knowledge of surface area of ​​3D models.

[Copyright Statement]
This article is an original article by the blogger. Reproduction without the permission of the blogger is strictly prohibited. We will conduct infringement searches regularly.

For more algorithm summaries, please follow my blog: https://blog.csdn.net/suiyingy, or the "Lele Perception School" official account.
This article comes from the series of articles in the column "Python 3D Model Processing Basics". The column address is: https://blog.csdn.net/suiyingy/category_12462636.html.

Guess you like

Origin blog.csdn.net/suiyingy/article/details/133971359