Method and device for generating directed bounding box of grid model, equipment and medium
By iteratively compute the triangle set and two-dimensional convex envelope segment set of the mesh model, a tighter directed enclosure box is generated, which solves the problem of inaccurate calculation of directed enclosure box in the prior art, and improves the accuracy of space utilization evaluation and collision detection.
Patent Information
- Application Number
- CN202510292889.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-06-24
AI Technical Summary
In the prior art, the directed enclosure box that uses principal component analysis methods to calculate the grid model may be larger than the actual required directed enclosure box, resulting in inaccurate evaluation of the space utilization of the object model in a three-dimensional environment.
By obtaining the data and geometric shape properties of the mesh model, a collection of line segments corresponding to the triangle set and the two-dimensional convex hull is obtained, and multiple iterative calculations are performed to generate the directed enclosure box of the mesh model.
The generated directed enclosure box surrounds the mesh model more closely, improving the accuracy of space utilization evaluation, and making collision detection results more accurate, while reducing data storage space and improving computing efficiency.
Smart Images

Figure CN120198614A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics, and particularly to a method and apparatus, device, and medium for generating an oriented bounding box of a mesh model. Background Art
[0002] In the field of computer graphics, in order to accurately reflect the physical contact and spatial relationship between objects in a three-dimensional environment, in application scenarios that require high accuracy such as precision mechanical design, medical surgery simulation, or high-end interactive video games, it is necessary to perform collision detection for each mesh in the model corresponding to the object. However, due to the complexity of the model, the computational complexity of collision detection is extremely high, and it is difficult to meet the requirements of real-time performance and efficiency due to the large amount of calculation. Therefore, in order to reduce the computational complexity and improve the detection efficiency, simplified methods such as calculating an Oriented Bounding Box (OBB) are usually used to approximately represent the meshes of complex models, and these oriented bounding boxes are used for collision detection to reduce the computational cost of performing collision detection on complex models and improve the detection efficiency.
[0003] However, the inventors found that existing methods for calculating the oriented bounding box of a mesh mainly calculate it through the Principal Components Analysis (PCA) method. However, PCA assumes that the principal components of the data points are the optimal directions. For some non-convex shapes (such as "L"-shaped or circular data) in the meshes of complex models, the principal component directions obtained by PCA may not truly provide the tightest bounding box of the mesh, that is, the oriented bounding box of the mesh calculated using PCA is larger than the actually required oriented bounding box, resulting in inaccurate evaluation of the space utilization rate of the model corresponding to the object in the three-dimensional environment, and further making the collision detection results of the model inaccurate. Summary of the Invention
[0004] This application provides a method and apparatus, device, and medium for generating an oriented bounding box of a mesh model to solve the problem that the oriented bounding box of the mesh model calculated using the principal component analysis method may be larger than the actually required oriented bounding box, resulting in inaccurate evaluation of the space utilization rate of the model corresponding to the object in the three-dimensional environment.
[0005] The first aspect of this application provides a method for generating an oriented bounding box of a mesh model, the method comprising:
[0006] Obtain data corresponding to the mesh model, wherein the mesh model includes a plurality of vertices;
[0007] Initialize parameters to obtain an initial length, an initial width, an initial height, an initial minimum area, an initial minimum horizontal axis value, an initial minimum vertical axis value, and an initial minimum vertical axis value;
[0008] Based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, obtain the set of triangles corresponding to the mesh model and the set of line segments corresponding to the two-dimensional convex hull of all vertices in the mesh model, and perform multiple iterative calculations on the set of triangles and the set of line segments respectively based on the initial length, initial width, initial height, initial minimum area, initial minimum horizontal axis value, initial minimum vertical axis value, and initial minimum perpendicular axis value to obtain the oriented bounding box of the mesh model.
[0009] In some embodiments of the present application, the oriented bounding box includes an origin, a direction rotation matrix, a length, a width, and a height, and the steps of performing multiple iterative calculations on the set of triangles and the set of line segments respectively to obtain the oriented bounding box of the mesh model include:
[0010] Perform multiple iterative calculations on the set of triangles based on the initial height and the initial minimum perpendicular axis value to obtain the target first quaternion, the target minimum perpendicular axis value, and the height of the oriented bounding box of the mesh model;
[0011] Based on the data corresponding to the mesh model, obtain the two-dimensional convex hull of all vertices in the mesh model, where the two-dimensional convex hull includes multiple line segments, and form a set of line segments with the multiple line segments, and perform multiple iterative calculations on the set of line segments based on the initial length, initial width, initial minimum area, initial minimum horizontal axis value, and initial minimum vertical axis value to obtain the target second quaternion, the target minimum horizontal axis value, the target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model;
[0012] Based on the target first quaternion and the target second quaternion, obtain the direction rotation matrix of the oriented bounding box of the mesh model;
[0013] Based on the target minimum horizontal axis value, the target minimum vertical axis value, the target minimum perpendicular axis value, and the direction rotation matrix of the oriented bounding box of the mesh model, obtain the origin of the oriented bounding box of the mesh model.
[0014] In some embodiments of the present application, the data corresponding to the mesh model includes: the coordinate data of each vertex in the mesh model in the initial three-dimensional coordinate system and the index data of each vertex in each triangle, and the steps of performing multiple iterative calculations on the set of triangles to obtain the target first quaternion, the target minimum perpendicular axis value, and the height of the oriented bounding box of the mesh model include:
[0015] In each iterative calculation process, randomly select an unprocessed triangle in the set of triangles, and based on the coordinate data of the three vertices of the triangle and the index data of each vertex in the triangle, construct vectors of any two sides, and perform a cross product calculation on the constructed vectors of the two sides to obtain the normal vector of the triangle;
[0016] Calculate a first quaternion from the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle, where the first quaternion indicates the rotation required to rotate the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle;
[0017] Perform parsing processing on the first quaternion to obtain a first rotation matrix;
[0018] Based on the coordinate data of all vertices in the mesh model and the first rotation matrix, obtain the new coordinate data of all vertices in the mesh model in the target three-dimensional coordinate system;
[0019] Compare the new coordinate data of all vertices in the mesh model on the z-axis of the target three-dimensional coordinate system, obtain the minimum coordinate data and the maximum coordinate data on the z-axis and calculate the difference between the two coordinate data;
[0020] Based on the difference and the initial height required for this iterative calculation, obtain the initial height and the initial minimum vertical axis value required for the next iterative calculation;
[0021] After completing multiple iterative calculations for all triangles in the triangle set according to the above steps, use the initial minimum vertical axis value and the initial height obtained after the last iterative calculation as the target minimum vertical axis value and the height of the oriented bounding box of the mesh model respectively, and use the first quaternion obtained during the process of obtaining the initial height in the last iterative calculation as the target first quaternion.
[0022] In some embodiments of the present application, the steps of obtaining the two-dimensional convex hull of all vertices in the mesh model based on the data corresponding to the mesh model include:
[0023] Based on the coordinate data of all vertices in the mesh model on the x-axis and y-axis of the target three-dimensional coordinate system, obtain the two-dimensional convex hull of all vertices in the mesh model, where the two-dimensional convex hull indicates a polygon that can enclose all vertices in the mesh model, and the polygon includes multiple vertices.
[0024] In some embodiments of the present application, the steps of performing multiple iterative calculations on the line segment set to obtain the target second quaternion, the target minimum horizontal axis value, the target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model include:
[0025] During each iterative calculation process, arbitrarily select an unprocessed line segment in the line segment set and calculate a second quaternion from the x-axis of the target three-dimensional coordinate system to the line segment, where the second quaternion indicates the rotation required to rotate the x-axis of the target three-dimensional coordinate system to the line segment;
[0026] Perform parsing processing on the second quaternion to obtain a second rotation matrix;
[0027] Based on the coordinate data of all vertices on the polygon and the second rotation matrix, obtain the new coordinate data of all vertices on the polygon in the target two-dimensional coordinate system;
[0028] Compare the new coordinate data of all vertices on the polygon on the x-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the x-axis and calculate the difference between the two coordinate data;
[0029] Compare the new coordinate data of all vertices on the polygon on the y-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the y-axis and calculate the difference between the two coordinate data;
[0030] Based on the two differences and the initial minimum area required for this iterative calculation, obtain the initial minimum area, initial length, initial width, initial minimum horizontal axis value, and initial minimum vertical axis value required for the next iterative calculation;
[0031] After completing multiple iterative calculations for all line segments in the polygon according to the above steps, use the initial minimum horizontal axis value, initial minimum vertical axis value, initial length, and initial width obtained after the last iterative calculation as the target minimum horizontal axis value, target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model, respectively, and use the second quaternion obtained during the process of obtaining the initial length and initial width in the last iterative calculation as the target second quaternion.
[0032] In some embodiments of the present application, the step of obtaining the direction rotation matrix of the oriented bounding box of the mesh model based on the target first quaternion and the target second quaternion includes:
[0033] Perform inverse operations on the target first quaternion and the target second quaternion respectively, and multiply the target first quaternion and the target second quaternion after the inverse operation to obtain a third quaternion;
[0034] Perform parsing processing on the third quaternion to obtain a third rotation matrix, where the third rotation matrix indicates the direction rotation matrix of the oriented bounding box of the mesh model.
[0035] In some embodiments of the present application, the step of obtaining the origin of the oriented bounding box of the mesh model based on the target minimum horizontal axis value, target minimum vertical axis value, target minimum vertical axis value, and the direction rotation matrix of the oriented bounding box of the mesh model includes:
[0036] Construct a matrix with the target minimum horizontal axis value, target minimum vertical axis value, and target minimum vertical axis value, and multiply the matrix by the third rotation matrix to obtain the origin of the oriented bounding box of the mesh model.
[0037] The second aspect of the present application provides an apparatus for generating an oriented bounding box of a mesh model, the apparatus includes:
[0038] A data acquisition module for acquiring data corresponding to a grid model, where the grid model includes multiple vertices;
[0039] An initialization data module for initializing parameters to obtain an initial length, an initial width, an initial height, an initial minimum area, an initial minimum horizontal axis value, an initial minimum vertical axis value, and an initial minimum vertical axis value;
[0040] An iterative calculation module for obtaining a set of triangles corresponding to the grid model and a set of line segments corresponding to the two-dimensional convex hull of all vertices in the grid model based on the data corresponding to the grid model and the geometric shape attributes of the grid model, and performing multiple iterative calculations on the set of triangles and the set of line segments respectively based on the initial length, the initial width, the initial height, the initial minimum area, the initial minimum horizontal axis value, the initial minimum vertical axis value, and the initial minimum vertical axis value to obtain an oriented bounding box of the grid model.
[0041] The third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in any one of the first aspects in the above embodiments are implemented.
[0042] The fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any one of the first aspects in the above embodiments is implemented.
[0043] The present application has the following beneficial effects:
[0044] Based on the data corresponding to the grid model and the geometric shape attributes of the grid model in the above embodiments of the present application, a set of triangles corresponding to the grid model and a set of line segments corresponding to the two-dimensional convex hull of the grid model are obtained, and multiple iterative calculations are performed on the set of triangles and the set of line segments respectively based on the initial length, the initial width, the initial height, the initial minimum area, the initial minimum horizontal axis value, the initial minimum vertical axis value, and the initial minimum vertical axis value to obtain an oriented bounding box of the grid model. The solution of the present application can generate a minimum oriented bounding box for the grid model for the set of triangles corresponding to the grid model and the set of line segments corresponding to the two-dimensional convex hull of the grid model, improving the accuracy of the spatial utilization rate evaluation of the model corresponding to the object in the three-dimensional environment and making the collision detection result of the model more accurate. At the same time, the iterative calculation method also reduces the data storage space and improves the calculation efficiency. Description of the Drawings
[0045] The drawings here are incorporated into the specification and constitute a part of the specification. These drawings show embodiments in line with the present application and are used together with the specification to illustrate the technical solutions of the present application.
[0046] Figure 1 It is a schematic diagram of an example of the oriented bounding box of the L-shaped structure in the grid obtained by using PCA provided by this application;
[0047] Figure 2 Schematic diagram of an example of the experimental results of the oriented bounding box generation scheme of this application and the prior art;
[0048] Figure 3 It is a schematic diagram of the process of the first embodiment of the method for generating the oriented bounding box of the grid model provided by this application;
[0049] Figure 4 It is a schematic diagram of the process of the second embodiment of the method for generating the oriented bounding box of the grid model provided by this application;
[0050] Figure 5 It is a schematic diagram of the process of an embodiment of the method for calculating the height of the oriented bounding box of the grid model provided by this application;
[0051] Figure 6 It is a schematic diagram of an example of the process of the method for calculating the height of the oriented bounding box of the grid model provided by this application;
[0052] Figure 7 It is a schematic diagram of an example of the method for calculating the normal vector of the triangle in the grid model provided by this application;
[0053] Figure 8 It is a schematic diagram of an example of the method for obtaining the target three-dimensional coordinate system provided by this application;
[0054] Figure 9 It is a schematic diagram of an example of the method for calculating the height of the oriented bounding box of the grid model provided by this application;
[0055] Figure 10 It is a schematic diagram of the process of an embodiment of the method for calculating the length and width of the oriented bounding box of the grid model provided by this application;
[0056] Figure 11 It is a schematic diagram of an example of the process of the method for calculating the length and width of the oriented bounding box of the grid model provided by this application;
[0057] Figure 12 It is a schematic diagram of an example of the iterative processing of the line segments in the two-dimensional convex hull provided by this application;
[0058] Figure 13 It is a schematic diagram of the process of an embodiment of the method for calculating the direction rotation matrix of the oriented bounding box of the grid model provided by this application;
[0059] Figure 14 It is a schematic diagram of the framework of an embodiment of the device for generating the oriented bounding box of the grid model provided by this application;
[0060] Figure 15It is a schematic diagram of the framework of an embodiment of the electronic device provided by this application;
[0061] Figure 16 It is a schematic diagram of the framework of an embodiment of the computer-readable storage medium provided by this application. Detailed implementation manners
[0062] Next, in conjunction with the accompanying drawings of the specification, the solutions of the embodiments of this application will be described in detail.
[0063] In the following description, specific details such as specific system architectures, interfaces, and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand this application.
[0064] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after. In addition, "multiple" in this article means two or more than two. In addition, the term "at least one" in this article represents any one of multiple or any combination of at least two of multiple. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set composed of A, B, and C.
[0065] As described in the background art, the grid-oriented bounding box calculated by PCA is larger than the required oriented bounding box, resulting in inaccurate evaluation of the space utilization rate of the model corresponding to the object in the three-dimensional environment, and further making the collision detection result of the model inaccurate.
[0066] For example, as Figure 1 shown, it shows the oriented bounding box of the L-shaped structure in the grid obtained by PCA. As can be seen from Figure 1 , PCA is used to find the principal component direction of the blue frame structure part of the grid model (i.e., the dotted line part in Figure 1 ), and the black box obtained based on the principal component direction is the oriented bounding box of the blue structure part. It can be seen that the oriented bounding box of the L-shaped structure calculated by the PCA method is not the smallest.
[0067] To solve the above problems, the present application proposes a new method for generating an oriented bounding box of a mesh model. In the solution of the present application, based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, a set of triangles corresponding to the mesh model and a set of line segments corresponding to the two-dimensional convex hull of the mesh model are obtained, and multiple iterative calculations are respectively performed on the set of triangles corresponding to the mesh model and the set of line segments corresponding to the two-dimensional convex hull of the mesh model, so as to generate a smallest oriented bounding box for the mesh model, improving the accuracy of the evaluation of the space utilization rate of the model corresponding to the object in the three-dimensional environment and making the collision detection result of the model more accurate. At the same time, the iterative calculation method also reduces the data storage space and improves the calculation efficiency.
[0068] For example, as Figure 2 shown, the red box part is the oriented bounding box generated for the blue box structure part by using the oriented bounding box generation method proposed in the present application. It can be seen from Figure 2 this that the smallest oriented bounding box can be generated for the blue box structure part by using the present application.
[0069] As can be seen from the above description, in the above embodiments of the present application, the iterative calculation method is used to perform iterative processing on the set of triangles corresponding to the mesh model and the set of line segments corresponding to the two-dimensional convex hull of the mesh model (iterative calculation means that the result of the previous calculation will be used as the input of the next calculation or as the determination condition for the start of the next calculation). This iterative calculation method can generate a smallest oriented bounding box for the mesh model according to the geometric shape attributes of the mesh model, improving the accuracy of the evaluation of the space utilization rate of the model corresponding to the object in the three-dimensional environment and further making the collision detection result of the model more accurate. At the same time, the iterative calculation method also reduces the data storage space and improves the calculation efficiency.
[0070] The present application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0071] I. Introduce the present application from the method aspect
[0072] According to an embodiment of the present application, the present application provides a method for generating an oriented bounding box of a mesh model, as Figure 3As shown, the method includes: S1. Obtain the data corresponding to the mesh model, where the mesh model includes multiple vertices; S2. Initialize parameters to obtain the initial length, initial width, initial height, initial minimum area, initial minimum horizontal axis value, initial minimum vertical axis value, and initial minimum vertical axis value; S3. Based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, obtain the triangle set corresponding to the mesh model and the line segment set corresponding to the two-dimensional convex hull of all vertices in the mesh model, and based on the initial length, initial width, initial height, initial minimum area, initial minimum horizontal axis value, initial minimum vertical axis value, and initial minimum vertical axis value, perform multiple iterative calculations on the triangle set and the line segment set respectively to obtain the oriented bounding box of the mesh model.
[0073] The inventor has found through research that the minimum oriented bounding box is generally defined as the minimum volume bounding box. However, for higher efficiency and to avoid full-scale calculations in this application, the minimum oriented bounding box in this application is defined as the minimum height and the minimum length-width area.
[0074] Therefore, according to the definition of the minimum oriented bounding box redefined in the above application, according to an embodiment of the application, the oriented bounding box includes an origin, a direction rotation matrix, a length, a width, and a height, and as Figure 4 shown, in step S3, this application obtains the oriented bounding box of the mesh model by performing the following steps S31 - S34: S31. Based on the initial height and the initial minimum vertical axis value, perform multiple iterative calculations on the triangle set to obtain the target first quaternion, the target minimum vertical axis value, and the height of the oriented bounding box of the mesh model; S32. Based on the data corresponding to the mesh model, obtain the two-dimensional convex hull of all vertices in the mesh model, where the two-dimensional convex hull includes multiple line segments, and form a line segment set with the multiple line segments, and based on the initial length, initial width, initial minimum area, initial minimum horizontal axis value, and initial minimum vertical axis value, perform multiple iterative calculations on the line segment set to obtain the target second quaternion, the target minimum horizontal axis value, the target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model; S33. Based on the target first quaternion and the target second quaternion, obtain the direction rotation matrix of the oriented bounding box of the mesh model; S34. Based on the target minimum horizontal axis value, the target minimum vertical axis value, the target minimum vertical axis value, and the direction rotation matrix of the oriented bounding box of the mesh model, obtain the origin of the oriented bounding box of the mesh model.
[0075] As can be seen from the above description, in the above embodiments of the present application, the height of the oriented bounding box is found by performing multiple iterative calculations on the triangle set corresponding to the mesh model, and the minimum area corresponding to the length and width of the oriented bounding box is found by performing multiple iterative calculations on the line segment set corresponding to the two-dimensional convex hull of the mesh model, thereby obtaining the length and width of the oriented bounding box. This way of dividing the oriented bounding box with the minimum volume into the minimum height and the minimum length-width area reduces the amount of calculation (i.e., the full-scale mode of calculating length * width * height is not required for each search), thereby improving the execution efficiency of the task.
[0076] To more clearly understand the solution of the above embodiments of the present application, the steps S31 - S34 will be described in detail below.
[0077] (1) Step S31
[0078] In step S31, based on the initial height and the initial minimum vertical axis value, multiple iterative calculations are performed on the triangle set to obtain the target first quaternion, the target minimum vertical axis value, and the height of the oriented bounding box of the mesh model.
[0079] Among them, according to an embodiment of the present application, the data corresponding to the mesh model includes: the coordinate data of each vertex of the mesh model in the initial three-dimensional coordinate system and the index data of each vertex in each triangle, and as Figure 5As shown in the figure, the present application obtains the target first quaternion, the target minimum vertical axis value, and the height of the oriented bounding box of the mesh model by performing the following steps S311 - S317: S311. In each iteration calculation process, randomly select an unprocessed triangle from the triangle set, and based on the coordinate data of the three vertices of the triangle and the index data of each vertex in the triangle, construct vectors of any two sides, and perform a cross product calculation on the constructed two side vectors to obtain the normal vector of the triangle; S312. Calculate the first quaternion from the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle, where the first quaternion indicates the rotation required to rotate the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle; S313. Perform an analytical process on the first quaternion to obtain the first rotation matrix; S314. Based on the coordinate data of all vertices in the mesh model and the first rotation matrix, obtain the new coordinate data of all vertices in the mesh model in the target three-dimensional coordinate system; S315. Compare the new coordinate data of all vertices in the mesh model on the z-axis of the target three-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the z-axis and calculate the difference between the two coordinate data; S316. Based on the difference and the initial height required for the current iteration calculation, obtain the initial height and the initial minimum vertical axis value required for the next iteration calculation; S317. After completing multiple iteration calculations for all triangles in the triangle set according to the above steps S311 - S316, take the initial minimum vertical axis value and the initial height obtained after the last iteration calculation as the target minimum vertical axis value and the height of the oriented bounding box of the mesh model respectively, and take the first quaternion obtained during the process of obtaining the initial height in the last iteration calculation as the target first quaternion.
[0080] As can be seen from the above description, in the above embodiment of the present application, by performing multiple iteration calculations on the triangle set corresponding to the mesh model to find the height of the oriented bounding box, the minimum height of the oriented bounding box of the mesh model can be accurately obtained. At the same time, by calculating the height of the oriented bounding box separately from the length and width, unnecessary traversals and volume calculations can be greatly reduced, improving the calculation efficiency.
[0081] Wherein, according to an embodiment of the present application, step S316 includes: comparing the difference between the minimum coordinate data and the maximum coordinate data on the z-axis with the initial height required for the current iteration calculation, and taking the smaller one as the initial height required for the next iteration calculation. When the difference is less than the initial height required for the current iteration calculation, take the difference as the initial height required for the next iteration calculation, and take the minimum coordinate data on the z-axis as the initial minimum vertical axis value required for the next iteration calculation; when the difference is greater than or equal to the initial height required for the current iteration calculation, take the initial height required for the current iteration calculation as the initial height required for the next iteration calculation, and take the initial minimum vertical axis value required for the current iteration calculation as the initial minimum vertical axis required for the next iteration calculation.
[0082] For example, initialize the length, width, height, minimum area, minimum horizontal axis value, minimum vertical axis value, and minimum vertical axis value to obtain the initial length L, initial width W, initial height minH, initial minimum area minArea, initial minimum horizontal axis value minX, initial minimum vertical axis value minY, and initial minimum vertical axis value minZ. As Figure 6 shown, it is a schematic flow diagram of the process for obtaining the height of the oriented bounding box of the mesh model by using iterative calculation. The process is as follows: First, obtain all triangles based on all vertices (v0, v1, v2,..., vn) in the mesh model; Second, arbitrarily select a triangle. As Figure 7 shown, take the triangle (v0v1v2) formed by the three vertices v0, v1, and v2 as an example. In the initial three-dimensional coordinate system CS1, the three vertices v0, v1, and v2 have corresponding coordinate data; Third, calculate the vectors m1 and m2 of the two sides (v2, v0) and (v1, v0) through the coordinate data of the three vertices, then n1 = m1·m2 is the normal vector of the triangle v0v1v2; Fourth, calculate the first quaternion Q1 from the z-axis of the initial coordinate system to the normal vector n1; Fifth, perform parsing processing on the first quaternion Q1 to obtain the first rotation matrix M1; Sixth, multiply all vertices (v0, v1, v2,..., vn) in the mesh model by M1 respectively to obtain the new coordinate data of all vertices (v0, v1, v2,..., vn) in the mesh model in the target three-dimensional coordinate system CS2. The result is as Figure 8 shown; Seventh, compare the new coordinate data of all vertices (v0, v1, v2,..., vn) on the z-axis of the target coordinate system CS2 to obtain the minimum coordinate data minZ1 and the maximum coordinate data maxZ1; Eighth, as Figure 9 shown, let maxZ1 - minZ1 = H1, and compare the size of H1 and the initial height minH. Among them, when H1 is less than minH, replace H1 with the initial height minH, and replace minZ1 with the initial minimum vertical axis value minZ. When H1 is greater than minH, the value of the initial height minH remains unchanged; Ninth, determine whether there are still triangles. If not, use the finally obtained initial height minH as the height of the oriented bounding box. Otherwise, use the smaller value of H1 and the initial height minH as the initial height required for the next iterative calculation; Tenth, after completing the calculation for all triangles according to the above iterative calculation method, use the initial height minH obtained from the last iterative calculation as the height of the oriented bounding box, and end the iterative calculation.
[0083] As can be seen from the above description, starting the next iterative calculation based on the initial height and the initial minimum vertical axis value obtained from the previous triangle can comprehensively consider the geometric shape characteristics of the mesh model to find the minimum height of the oriented bounding box.
[0084] (2) Step S32
[0085] In step S32, based on the data corresponding to the grid model, a two-dimensional convex hull of all vertices in the grid model is obtained, where the two-dimensional convex hull includes multiple line segments, and the multiple line segments form a line segment set. And based on the initial length, initial width, initial minimum area, initial minimum horizontal axis value, and initial minimum vertical axis value, the line segment set is iteratively calculated multiple times to obtain the target second quaternion, target minimum horizontal axis value, target minimum vertical axis value, the length and width of the oriented bounding box of the grid model.
[0086] In the above embodiment, the calculation of the height of the oriented bounding box of the grid model is completed. Therefore, in order to further reduce the calculation amount and improve the calculation efficiency, this application ignores the coordinate data of all vertices in the grid model on the z-axis, converts the three-dimensional data of the vertices into two-dimensional data, and obtains the length and width of the oriented bounding box based on the two-dimensional coordinate data of all vertices.
[0087] For this reason, according to an embodiment of this application, based on the coordinate data of all vertices in the grid model on the x-axis and y-axis of the target three-dimensional coordinate system, a two-dimensional convex hull of all vertices in the grid model is obtained, where the two-dimensional convex hull indicates a polygon that can enclose all vertices in the grid model, and the polygon includes multiple vertices. Among them, according to another embodiment of this application, the quick hull method of the two-dimensional convex hull is used to process the coordinate data of all vertices in the grid model on the x-axis and y-axis of the target three-dimensional coordinate system to obtain the two-dimensional convex hull of all vertices in the grid model.
[0088] As can be seen from the above description, this application converts the three-dimensional data of the vertices into two-dimensional data, and obtains the length and width of the oriented bounding box based on the two-dimensional coordinate data of all vertices. While obtaining the accurate and minimum length and width of the oriented bounding box, the calculation amount is reduced, thereby improving the calculation efficiency.
[0089] Among them, according to an embodiment of this application, such as Figure 10As shown, the present application obtains the target second quaternion, the target minimum horizontal axis value, the target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model by performing the following steps S321 - S32: S321. In each iterative calculation process, arbitrarily select an unprocessed line segment in the line segment set, and calculate the second quaternion of the x-axis of the target three-dimensional coordinate system to the line segment, where the second quaternion indicates the rotation required to rotate the x-axis of the target three-dimensional coordinate system to the line segment; S322. Perform parsing processing on the second quaternion to obtain a second rotation matrix; S323. Based on the coordinate data of all vertices on the polygon and the second rotation matrix, obtain the new coordinate data of all vertices on the polygon in the target two-dimensional coordinate system; S324. Compare the new coordinate data of all vertices on the polygon on the x-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the x-axis and calculate the difference between the two coordinate data; S325. Compare the new coordinate data of all vertices on the polygon on the y-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the y-axis and calculate the difference between the two coordinate data; S326. Based on the two differences and the initial minimum area required for the current iterative calculation, obtain the initial minimum area, the initial length, the initial width, the initial minimum horizontal axis value, and the initial minimum vertical axis value required for the next iterative calculation; S327. After completing multiple iterative calculations for all line segments in the polygon according to the above steps S321 - S327, take the initial minimum horizontal axis value, the initial minimum vertical axis value, the initial length, and the initial width obtained after the last iterative calculation as the target minimum horizontal axis value, the target minimum vertical axis value, the length and width of the oriented bounding box of the mesh model, respectively, and take the second quaternion obtained during the process of obtaining the initial length and the initial width in the last iterative calculation as the target second quaternion.
[0090] Among them, according to an embodiment of the present application, step S326 includes: multiplying the difference between the minimum coordinate data and the maximum coordinate data on the x-axis by the difference between the minimum coordinate data and the maximum coordinate data on the y-axis to obtain the area corresponding to the difference, and comparing the area corresponding to the difference with the initial minimum area required for the current iterative calculation, and taking the smaller one as the initial minimum area required for the next iterative calculation. Wherein, when the area corresponding to the difference is less than the initial minimum area required for the current iterative calculation, the area corresponding to the difference is used as the initial minimum area required for the next iterative calculation, the minimum coordinate data on the x-axis is used as the initial minimum horizontal axis value required for the next iterative calculation, and the minimum coordinate data on the y-axis is used as the initial minimum vertical axis value required for the next iterative calculation; when the area corresponding to the difference is greater than or equal to the initial minimum area required for the current iterative calculation, the initial minimum area required for the current iterative calculation is used as the initial minimum area required for the next iterative calculation, the initial minimum horizontal axis value required for the current iterative calculation is used as the initial minimum horizontal axis value required for the next iterative calculation, and the initial minimum vertical axis value required for the current iterative calculation is used as the initial minimum vertical axis value required for the next iterative calculation.
[0091] For example, as Figure 11 shown, it is an example schematic diagram of obtaining the length and width of the oriented bounding box of the grid model by using the iterative calculation method. The process is as follows: First, obtain the corresponding two-dimensional convex hull based on all the vertices (v0, v1, v2,..., vn) in the grid model. Among them, the two-dimensional convex hull includes multiple vertices (p0, p1, p2,..., pn), and multiple line segments of the two-dimensional convex hull obtained based on all the vertices (p0, p1, p2,..., pn) of the two-dimensional convex hull; Second, as Figure 12 (a) shown, arbitrarily select a line segment (p0, p1) in the two-dimensional convex hull; Third, calculate the second quaternion Q2 from the x-axis of the target three-dimensional coordinate system CS2 to the line segment (p0, p1); Fourth, perform parsing processing on Q2 to obtain the second rotation matrix M2; Fifth, multiply the coordinate data of all the vertices (p0, p1, p2,..., pn) of the two-dimensional convex hull by M2 respectively to obtain the new coordinate data of all the vertices (p0, p1, p2,..., pn) in the target two-dimensional coordinate system; Sixth, as Figure 12(As shown in (b), compare the new coordinate data of all vertices (p0, p1, p2,..., pn) on the x-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data minX1 and the maximum coordinate data maxX1 on the x-axis; seventh, compare the new coordinate data of all vertices (p0, p1, p2,..., pn) on the y-axis of the target two-dimensional coordinate system CS3 to obtain the minimum coordinate data minY1 and the maximum coordinate data maxY1 on the y-axis; eighth, let maxX1 - minX1 = L1, maxY1 - minY1 = W1, and compare the size of the product L1 * W1 = minArea1 and the initial minimum area minArea. When minArea1 is smaller, replace the initial minimum area minArea with minArea1, replace the initial length L with L1, replace the initial width W with W1, replace the initial minimum horizontal axis value minX with minX1, and replace the initial minimum vertical axis value minY with minY1; ninth, determine whether there are still line segments. If not, use the finally obtained initial length L and initial width W as the length and width of the oriented bounding box. Otherwise, use the smaller value between minArea1 and minArea as the initial minimum area required for the next iterative calculation; tenth, after completing the calculation for all line segments in the two-dimensional convex hull according to the above iterative calculation method, use the initial length and initial width obtained from the last iterative calculation as the length and width of the oriented bounding box.)
[0092] As can be seen from the above description, starting from the initial length, initial width, and initial minimum area obtained based on a line segment in the two-dimensional convex hull, perform iterative calculations for another line segment in the two-dimensional convex hull, which can comprehensively consider the structural characteristics of the two-dimensional convex hull of the mesh model to find the minimum length and width of the oriented bounding box.)
[0093] (III) Step S33
[0094] In step S33, based on the target first quaternion and the target second quaternion, obtain the direction rotation matrix of the oriented bounding box of the mesh model.)
[0095] Among them, according to an embodiment of the present application, as Figure 13 shown, the present application obtains the direction rotation matrix of the oriented bounding box of the mesh model by executing steps S331 - S332: S331, perform inverse operations on the target first quaternion and the target second quaternion respectively, and multiply the target first quaternion and the target second quaternion after the inverse operation to obtain a third quaternion; S332, perform parsing processing on the third quaternion to obtain a third rotation matrix, where the third rotation matrix indicates the direction rotation matrix of the oriented bounding box of the mesh model.)
[0096] For example, invert Q1 and Q2 to obtain Q1 -1 and Q2 -1 , and let Q1-1 and Q2 -1 Multiply them to obtain the third quaternion Q3, and analyze Q3 to obtain the third rotation matrix M3, that is, obtain the directional rotation matrix of the oriented bounding box.
[0097] As can be seen from the above description, in the above embodiments of the present application, by introducing the concepts of quaternion, its inverse operation, and rotation matrix, the accurate calculation of the directional rotation matrix of the oriented bounding box of the mesh model is realized.
[0098] (IV) Step S34
[0099] In step S34, based on the target minimum horizontal axis value, the target minimum vertical axis value, the target minimum vertical axis value, and the directional rotation matrix of the oriented bounding box of the mesh model, the origin of the oriented bounding box of the mesh model is obtained.
[0100] Wherein, according to an embodiment of the present application, step S34 includes: forming a matrix with the target minimum horizontal axis value, the target minimum vertical axis value, and the target minimum vertical axis value, and multiplying the matrix by the third rotation matrix to obtain the origin of the oriented bounding box of the mesh model.
[0101] For example, multiply (minX, minY, minZ) obtained from the last iterative calculation by M3, and the result is the origin of the oriented bounding box of the mesh model.
[0102] As can be seen from the above description, in the above embodiments of the present application, by multiplying the initial minimum horizontal axis value, the initial minimum vertical axis value, and the initial minimum vertical axis value obtained after the last iterative calculation by the third quaternion, the origin of the oriented bounding box of the mesh model is directly calculated. This method cleverly utilizes the advantage of quaternion in representing rotation in three-dimensional space, ensuring the accuracy and efficiency of the origin calculation, that is, simplifying the traditionally complex coordinate transformation process, thereby improving the speed and accuracy of three-dimensional object positioning and orientation processing.
[0103] II. Expand the introduction of the present application from the system side
[0104] According to an embodiment of the present application, the present application provides a generating device for an oriented bounding box of a mesh model, as Figure 14As shown in the figure, the device includes: a data acquisition module for acquiring data corresponding to a mesh model, where the mesh model includes multiple vertices; an initialization data module for initializing parameters to obtain an initial length, an initial width, an initial height, an initial minimum area, an initial minimum horizontal axis value, an initial minimum vertical axis value, and an initial minimum vertical axis value; and an iterative calculation module for obtaining a set of triangles corresponding to the mesh model and a set of line segments corresponding to the two-dimensional convex hull of all vertices in the mesh model based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, and performing multiple iterative calculations on the set of triangles and the set of line segments respectively based on the initial length, the initial width, the initial height, the initial minimum area, the initial minimum horizontal axis value, the initial minimum vertical axis value, and the initial minimum vertical axis value to obtain an oriented bounding box of the mesh model.
[0105] In summary, compared with the existing method of calculating the oriented bounding box of a mesh model using the PCA method, in the above embodiments of the present application, a set of triangles corresponding to the mesh model and a set of line segments corresponding to the two-dimensional convex hull of the mesh model are obtained based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, and multiple iterative calculations are performed on the set of triangles and the set of line segments respectively based on the initial length, the initial width, the initial height, the initial minimum area, the initial minimum horizontal axis value, the initial minimum vertical axis value, and the initial minimum vertical axis value to obtain an oriented bounding box of the mesh model. The solution of the present application can generate a minimum oriented bounding box for the mesh model for the set of triangles corresponding to the mesh model and the set of line segments corresponding to the two-dimensional convex hull of the mesh model, improving the accuracy of the spatial utilization rate evaluation of the model corresponding to the object in a three-dimensional environment and making the collision detection result of the model more accurate. At the same time, the iterative calculation method also reduces the data storage space and improves the calculation efficiency. At the same time, the iterative calculation method and the method of dividing the oriented bounding box with the minimum volume into the minimum height and the minimum length-width area reduce the calculation amount (i.e., the full amount mode of calculating length * width * height is not required for each search), and also reduce the data storage space and improve the calculation efficiency.
[0106] Based on the inventive concept of the above embodiments, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the above embodiments are implemented. The following is combined with Figure 15 for a detailed description.
[0107] As Figure 15 shown, it shows the electronic device of the present application, which may specifically include a processor 110 and a memory 120. The memory 120 is coupled to the processor 110.
[0108] The processor 110 is used to control the operation of the electronic device. The processor 110 may also be referred to as a CPU (Central Processing Unit). The processor 110 may be an integrated circuit chip with the ability to process signals. The processor 110 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor 110 may also be any conventional processor, etc.
[0109] The memory 120 is used to store computer programs and may be a RAM, a ROM, or other types of storage terminals. Specifically, the memory 120 may include one or more computer-readable storage media, which may be non-transitory or transitory. The memory 120 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage terminals, flash memory storage terminals. In some embodiments, the non-transitory computer-readable storage media in the memory 120 is used to store at least one program code.
[0110] The processor 110 is used to execute the computer programs stored in the memory 120 to implement the methods described in the method embodiments of the present application.
[0111] In some embodiments, the electronic device may further include: a peripheral terminal interface 130 and at least one peripheral terminal. The processor 110, the memory 120, and the peripheral terminal interface 130 may be connected through a bus or signal lines. Each peripheral terminal may be connected to the peripheral terminal interface 130 through a bus, signal lines, or a circuit board. Specifically, the peripheral terminal includes at least one of a radio frequency circuit 140, a display screen 150, an audio circuit 160, and a power supply 170.
[0112] The peripheral terminal interface 130 may be used to connect at least one peripheral terminal related to I / O (Input / Output) to the processor 110 and the memory 120. In some embodiments, the processor 110, the memory 120, and the peripheral terminal interface 130 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 110, the memory 120, and the peripheral terminal interface 130 may be implemented on separate chips or circuit boards, and this embodiment does not limit this.
[0113] The radio frequency circuit 140 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 140 communicates with the communication network and other Internet of Things devices through electromagnetic signals, and the radio frequency circuit 140 is the communication circuit of the electronic device. The radio frequency circuit 140 converts electrical signals into electromagnetic signals for transmission, or converts the received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 140 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, an operator identity module card, and so on. The radio frequency circuit 140 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 140 may further include a circuit related to NFC (Near Field Communication), which is not limited in this application.
[0114] The display screen 150 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 150 is a touch display screen, the display screen 150 also has the ability to collect touch signals on or above the surface of the display screen 150. The touch signals can be input to the processor 110 for processing as control signals. At this time, the display screen 150 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 150, which is set on the front panel of the electronic device; in other embodiments, there may be at least two display screens 150, which are respectively set on different surfaces of the electronic device or are in a folded design; in other embodiments, the display screen 150 may be a flexible display screen, which is set on the curved surface or the folding surface of the electronic device. Even, the display screen 150 can be set into an irregular non-rectangular shape, that is, a special-shaped screen. The display screen 150 can be prepared from materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0115] The audio circuit 160 may include a microphone and a speaker. The microphone is used to collect sound waves of the operator and the environment, and convert the sound waves into electrical signals for input to the processor 110 for processing, or input to the radio frequency circuit 140 to achieve voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the electronic device. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from the processor 110 or the radio frequency circuit 140 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 160 may further include a headphone jack.
[0116] The power supply 170 is used to supply power to each component in the electronic device. The power supply 170 may be alternating current, direct current, a disposable battery or a rechargeable battery. When the power supply 170 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0117] For a detailed description of the functions and execution processes of each functional module or component in the electronic device embodiments of this application, reference may be made to the descriptions in the above method embodiments of this application, and details will not be repeated here.
[0118] In several embodiments provided in this application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the electronic device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of devices or units can be in electrical, mechanical or other forms.
[0119] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] In addition, in each embodiment of the present application, each functional unit can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0121] Based on the inventive concept of the above embodiments, the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the method described in any of the above embodiments. The following will be combined with Figure 16 to illustrate the execution process of the above embodiments in the computer-readable storage medium.
[0122] As Figure 16 shown, it shows the computer-readable storage medium of the present application. If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the computer-readable storage medium 200. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions / computer programs to enable an Internet of Things device (which can be a personal computer, a server, or a network terminal, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs, as well as electronic terminals such as computers, mobile phones, laptop computers, tablet computers, and cameras having the above storage media.
[0123] The description of the execution process of the program data in the computer-readable storage medium can be referred to the description in the method embodiments of the present application above, and will not be repeated here.
[0124] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
[0125] Those skilled in the art can understand that in the above method of the specific implementation manner, the writing order of each step does not mean a strict execution order and does not constitute any limitation to the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.
Claims
1. A method for generating a directed bounding box of a mesh model, characterized in that: The method comprises: Acquire data corresponding to a mesh model, wherein the mesh model includes a plurality of vertices; Initialize parameters to obtain initial length, initial width, initial height, initial minimum area, initial minimum horizontal axis value, initial minimum vertical axis value, and initial minimum vertical axis value; Based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, a triangle set corresponding to the mesh model and a line segment set corresponding to the two-dimensional convex hull of all vertices in the mesh model are obtained, and based on the initial length, initial width, initial height, initial minimum area, initial minimum horizontal axis value, initial minimum vertical axis value, and initial minimum vertical axis value, multiple iterative calculations are performed on the triangle set and the line segment set, respectively, to obtain a directed bounding box of the mesh model.
2. The method for generating a directed bounding box of a mesh model according to claim 1, characterized in that: The directed bounding box includes an origin, a direction rotation matrix, a length, a width, and a height, and the steps of performing multiple iterative calculations on the triangle set and the line segment set to obtain the directed bounding box of the mesh model include: Based on the initial height and the initial minimum vertical axis value, performing multiple iterative calculations on the triangle set to obtain a target first quaternion, a target minimum vertical axis value, and a height of the directed bounding box of the mesh model; Based on the data corresponding to the mesh model, a two-dimensional convex hull of all vertices in the mesh model is obtained, wherein the two-dimensional convex hull includes a plurality of line segments, and the plurality of line segments constitute a line segment set, and based on the initial length, the initial width, the initial minimum area, the initial minimum horizontal axis value, and the initial minimum vertical axis value, the line segment set is iteratively calculated multiple times to obtain a target second quaternion, a target minimum horizontal axis value, a target minimum vertical axis value, and the length and width of the directed bounding box of the mesh model; Based on the target first quaternion and the target second quaternion, a direction rotation matrix of the directed bounding box of the mesh model is obtained; Based on the target minimum horizontal axis value, the target minimum vertical axis value, the target minimum vertical axis value, and the direction rotation matrix of the grid model directed bounding box, the origin of the grid model directed bounding box is obtained.
3. The method for generating a directed bounding box of a mesh model according to claim 2, characterized in that: The data corresponding to the mesh model includes: coordinate data of each vertex in the mesh model in an initial three-dimensional coordinate system and index data of each vertex in each triangle, and the step of performing multiple iterative calculations on the triangle set to obtain a target first quaternion, a target minimum vertical axis value, and a height of a directed bounding box of the mesh model includes: In each iterative calculation process, an unprocessed triangle is randomly selected from the triangle set, and vectors of any two edges are constructed based on the coordinate data of the three vertices of the triangle and the index data of each vertex in the triangle, and a cross product calculation is performed on the constructed vectors of the two edges to obtain a normal vector of the triangle; Calculate a first quaternion from the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle, wherein the first quaternion indicates the rotation required to rotate the z-axis of the initial three-dimensional coordinate system to the normal vector of the triangle; Analytically processing the first quaternion to obtain a first rotation matrix; Based on the coordinate data of all vertices in the mesh model and the first rotation matrix, obtaining new coordinate data of all vertices in the mesh model in a target three-dimensional coordinate system; Comparing the new coordinate data of all vertices in the mesh model on the z-axis of the target three-dimensional coordinate system, obtaining the minimum coordinate data and the maximum coordinate data on the z-axis and calculating the difference between the two coordinate data; Based on the difference and the initial height required for this iterative calculation, the initial height and the initial minimum vertical axis value required for the next iterative calculation are obtained; After completing multiple iterative calculations for all triangles in the triangle set according to the above steps, the initial minimum vertical axis value and the initial height obtained after the last iterative calculation are used as the target minimum vertical axis value and the height of the directed bounding box of the mesh model respectively, and the first quaternion obtained in the process of obtaining the initial height in the last iterative calculation is used as the target first quaternion.
4. The method for generating a directed bounding box of a mesh model according to claim 2, characterized in that: The step of obtaining the two-dimensional convex hull of all vertices in the mesh model based on the data corresponding to the mesh model comprises: Based on the coordinate data of all vertices in the mesh model on the x-axis and y-axis of the target three-dimensional coordinate system, a two-dimensional convex hull of all vertices in the mesh model is obtained, wherein the two-dimensional convex hull indicates a polygon that can surround all vertices in the mesh model, and the polygon includes multiple vertices.
5. The method for generating a directed bounding box of a mesh model according to claim 4, characterized in that: The step of performing multiple iterative calculations on the line segment set to obtain a target second quaternion, a target minimum horizontal axis value, a target minimum vertical axis value, and the length and width of the directed bounding box of the mesh model comprises: In each iterative calculation process, arbitrarily select an unprocessed line segment in the line segment set, and calculate a second quaternion from the x-axis of the target three-dimensional coordinate system to the line segment, wherein the second quaternion indicates the rotation required to rotate the x-axis of the target three-dimensional coordinate system to the line segment; Performing analytical processing on the second quaternion to obtain a second rotation matrix; Based on the coordinate data of all vertices on the polygon and the second rotation matrix, obtaining new coordinate data of all vertices on the polygon in a target two-dimensional coordinate system; Comparing the new coordinate data of all vertices on the polygon on the x-axis of the target two-dimensional coordinate system to obtain the minimum coordinate data and the maximum coordinate data on the x-axis and calculate the difference between the two coordinate data; Compare the new coordinate data of all vertices on the polygon on the y-axis of the target two-dimensional coordinate system, obtain the minimum coordinate data and the maximum coordinate data on the y-axis and calculate the difference between the two coordinate data; Based on the two differences and the initial minimum area required for this iteration calculation, the initial minimum area, initial length, initial width, initial minimum horizontal axis value, and initial minimum vertical axis value required for the next iteration calculation are obtained; After completing multiple iterative calculations for all the line segments in the polygon according to the above steps, the initial minimum horizontal axis value, initial minimum vertical axis value, initial length, and initial width obtained after the last iterative calculation are used as the target minimum horizontal axis value, target minimum vertical axis value, length and width of the directed bounding box of the grid model, respectively, and the second quaternion obtained in the process of obtaining the initial length and initial width through the last iterative calculation is used as the target second quaternion.
6. The method for generating a directed bounding box of a mesh model according to claim 5, characterized in that: The step of obtaining a direction rotation matrix of the directed bounding box of the mesh model based on the target first quaternion and the target second quaternion comprises: Performing inversion operations on the target first quaternion and the target second quaternion respectively, and multiplying the target first quaternion and the target second quaternion after the inversion operation to obtain a third quaternion; The third quaternion is analyzed to obtain a third rotation matrix, wherein the third rotation matrix indicates a direction rotation matrix of the bounding box of the mesh model.
7. The method for generating a directed bounding box of a mesh model according to claim 6, characterized in that: The step of obtaining the origin of the directed bounding box of the grid model based on the target minimum horizontal axis value, the target minimum vertical axis value, the target minimum vertical axis value, and the direction rotation matrix of the directed bounding box of the grid model comprises: The target minimum horizontal axis value, the target minimum vertical axis value, and the target minimum vertical axis value are formed into a matrix, and the matrix is multiplied with the third rotation matrix to obtain the origin of the directed bounding box of the grid model.
8. A device for generating a directed bounding box of a grid model, characterized in that: The device comprises: A data acquisition module, used to acquire data corresponding to a mesh model, wherein the mesh model includes a plurality of vertices; Initialize the data module, which is used to initialize the length, width, height, minimum area, minimum horizontal axis value, minimum vertical axis value, and minimum vertical axis value; An iterative calculation module is used to obtain a triangle set corresponding to the mesh model and a line segment set corresponding to the two-dimensional convex hull of all vertices in the mesh model based on the data corresponding to the mesh model and the geometric shape attributes of the mesh model, and to perform multiple iterative calculations on the triangle set and the line segment set based on an initial length, an initial width, an initial height, an initial minimum area, an initial minimum horizontal axis value, an initial minimum vertical axis value, and an initial minimum vertical axis value, so as to obtain a directed bounding box of the mesh model.
9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Map data processing method and device based on model reconstruction, equipment and medium
CN120707771A
Map data processing methods, apparatus, equipment, and media based on model reconstruction
CN120707771B