Method and device for calculating and displaying shortest distance position between three-dimensional model objects

By generating the method of enclosing box and connecting line segments, the shortest distance between the three-dimensional model objects is screened and displayed, the problem of inefficiency in the prior art is solved, and efficient calculation and display is achieved.

CN120451255AActive Publication Date: 2025-08-08VKINGTELE INTELLIGENT TECHNOLOGY (SHANGHAI) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510529845.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-08
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

The prior art is inefficient and consumes a lot of computing resources when calculating the shortest distance between three-dimensional model objects, especially for non-convex geometry and fine models.

Method used

By generating the enclosure box of the object model, connecting the center point of the enclosure box to generate the model center connection segment, and generating the distance calculation range based on the line segment, filtering out the overlapping vertices, selecting the pair of vertices with the shortest spatial distance as the target vertices, and displaying the shortest distance position.

Benefits of technology

The spatial point position data obtained when calculating the shortest distance is reduced, and the calculation and display efficiency of the shortest distance between three-dimensional model objects is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120451255A_ABST
    Figure CN120451255A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of three-dimensional modeling, discloses a method and a device for calculating and displaying the position of the shortest distance between three-dimensional model objects, electronic equipment, a computer readable storage medium and a computer program product, and aims to solve the problems that the efficiency is low when the shortest distance between the three-dimensional model objects is calculated and displayed; and a large amount of computing resources need to be consumed. The method comprises the following steps: respectively generating bounding boxes of a first object model and a second object model, connecting center points of the two bounding boxes to generate a model center connecting line segment, and generating a distance calculation range; respectively screening out vertexes coinciding with the distance calculation range from the first object model and the second object model, respectively selecting the vertexes to obtain a plurality of vertex pairs from different object models, and selecting a pair of vertex pairs with the shortest spatial distance from the vertex pairs as target vertexes, and displaying the shortest distance position of the first object model and the second object model based on the target vertex.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of three-dimensional modeling technology, and in particular to a method, device, electronic device, computer storage medium, and computer program product for calculating and displaying the shortest distance between three-dimensional model objects. Background Art

[0002] A 3D mesh model is a mathematical model that represents the surface or solid of a 3D object using a set of vertices, edges, and faces. It discretizes an object in 3D space into a finite set of geometric elements, such as triangles and quadrilaterals. By defining the coordinates of the polygon vertices and their connections, the object's shape and surface features can be fully described. It has widespread applications in computer graphics, computer-aided design, and vision.

[0003] For example, in the use of three-dimensional mesh models in business scenarios such as industrial digital twins, it is often necessary to display the shortest path between two objects (such as two devices). In the prior art, when calculating three-dimensional polygonal objects, commonly used algorithms such as the GJK (Gilbert-Johnson-Keerthi) algorithm and the SAT (Separating Axis Theorem) algorithm are generally used to calculate the distance between three-dimensional polygonal objects, but they all require that the objects involved in the calculation be convex geometric bodies. However, the objects (devices) in many business scenarios are usually non-convex, so these objects need to be disassembled into convex models before they can be calculated. In addition, detailed object (device) models often contain millions or even tens of millions of vertices, which will occupy a large amount of business computing resources during calculation and cause response delays; however, in business scenarios such as industrial digital twins where precise calculations are not required, such a solution will result in inefficient distance display and a large amount of computing data consumed.

[0004] Based on this, there is an urgent need for a method for calculating and displaying the shortest distance position between three-dimensional model objects, which can reduce the data consumption of calculating the shortest distance between three-dimensional model objects while improving the display efficiency of the shortest distance between three-dimensional model objects. Summary of the Invention

[0005] The main purpose of the present invention is to solve the technical problems in the prior art of calculating and displaying the shortest distance between three-dimensional model objects, which are low efficiency and require a large amount of computing resources.

[0006] A first aspect of the present invention provides a method for calculating and displaying the shortest distance between three-dimensional model objects, comprising:

[0007] Generating bounding boxes for the first object model and the second object model respectively, connecting the center points of the two bounding boxes to generate a model center connecting line segment, and generating a distance calculation range based on the model center connecting line segment;

[0008] Filtering out vertices that overlap with the distance calculation range in the first object model and the second object model respectively to obtain a first vertex data set and a second vertex data set;

[0009] Vertices are selected from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, a pair of vertex pairs with the shortest spatial distance among the vertex pairs is selected as the target vertex, and the shortest distance position between the first object model and the second object model is displayed based on the target vertex.

[0010] Optionally, in a first implementation of the first aspect of the present invention, generating a distance calculation range based on the model center connecting line segments includes:

[0011] Based on the length of the line segment connecting the center of the model as the range sphere diameter, a range sphere is drawn with the midpoint of the line segment connecting the center of the model as the sphere center to obtain the distance calculation range.

[0012] Optionally, in a second implementation of the first aspect of the present invention, the distance calculation range includes a first distance calculation range and a second distance calculation range, the range sphere includes a first range sphere and a second range sphere, and the range sphere diameter includes a first range sphere diameter and a second range sphere diameter;

[0013] Generating a distance calculation range based on the model center connecting line segments includes:

[0014] determining a first enclosing ratio and a second enclosing ratio;

[0015] Calculate a first range sphere diameter and a second range sphere diameter respectively according to the length of the connecting line segment of the model center, the first enclosing ratio, and the second enclosing ratio;

[0016] The midpoint of the line segment is used as the sphere center, and the first range sphere diameter and the second range sphere diameter are used as the first range sphere diameter and the second range sphere diameter respectively to obtain the first distance calculation range and the second distance calculation range.

[0017] Optionally, in a third implementation of the first aspect of the present invention, the filtering out vertices that overlap with the distance calculation range in the first object model and the second object model respectively to obtain the first vertex dataset and the second vertex dataset includes:

[0018] Screening out vertices that coincide with the first distance calculation range in the first object model to obtain a first vertex data set;

[0019] Vertices that coincide with the second distance calculation range are screened out in the second object model to obtain a first vertex data set.

[0020] Optionally, in a fourth implementation manner of the first aspect of the present invention, selecting vertices from the first vertex dataset and the second vertex dataset respectively to obtain multiple vertex pairs from different object models, and selecting a vertex pair with the shortest spatial distance among the vertex pairs as the target vertex includes:

[0021] According to the coding sorting rule, sorting and numbering the vertices of the first vertex data set and the second vertex data set respectively;

[0022] randomly generating a plurality of first random numbers and a plurality of second random numbers using a pseudo-random algorithm to obtain a plurality of random number pairs;

[0023] Obtaining a vertex corresponding to the first random number in the first vertex data set according to the vertex number; obtaining a vertex corresponding to the second random number in the second vertex data set according to the vertex number, to obtain a plurality of vertex pairs from different object models;

[0024] The coordinate information of the plurality of vertex pairs is obtained and the distance between the vertex pairs is calculated, and a vertex pair with the shortest distance between the vertex pairs is selected as the target vertex.

[0025] Optionally, in a fifth implementation of the first aspect of the present invention, the bounding box is a minimum circumscribed rectangular bounding box.

[0026] A second aspect of the present invention provides a device for calculating and displaying the shortest distance between three-dimensional model objects, comprising:

[0027] a range acquisition module, configured to generate bounding boxes for the first object model and the second object model, respectively, connect the center points of the two bounding boxes to generate a model center connecting line segment, and generate a distance calculation range based on the model center connecting line segment;

[0028] a vertex screening module, configured to screen out vertices overlapping with the distance calculation range in the first object model and the second object model respectively, to obtain a first vertex data set and a second vertex data set;

[0029] A distance calculation module is used to select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a pair of vertex pairs with the shortest spatial distance as the target vertex, and display the shortest distance position between the first object model and the second object model based on the target vertex.

[0030] The third aspect of the present invention provides a device for calculating and displaying the shortest distance position between three-dimensional model objects, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory to enable the device for calculating and displaying the shortest distance position between three-dimensional model objects to execute the steps of the above-mentioned method for calculating and displaying the shortest distance position between three-dimensional model objects.

[0031] A fourth aspect of the present invention provides a computer-readable storage medium, which stores instructions that, when run on a computer, enable the computer to execute the steps of the above-mentioned method for calculating and displaying the shortest distance between three-dimensional model objects.

[0032] The fifth aspect of the present invention provides a computer program product, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the steps of the method for calculating and displaying the shortest distance between three-dimensional model objects as described above are implemented.

[0033] In the technical solution provided by the present invention, bounding boxes of a first object model and a second object model are generated respectively, the center points of the two bounding boxes are connected to generate a model center connecting line segment, and a distance calculation range is generated based on the model center connecting line segment; vertices that coincide with the distance calculation range are screened out in the first object model and the second object model respectively to obtain a first vertex data set and a second vertex data set; vertices are selected in the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, a pair of vertices with the shortest spatial distance among the vertex pairs is selected as the target vertex, and the shortest distance position between the first object model and the second object model is displayed based on the target vertex. The technical solution provided by the present invention can reduce the spatial point position data that needs to be obtained when calculating the shortest distance, and can improve the efficiency of calculating and displaying the shortest distance between three-dimensional model objects.

[0034] The device, electronic device, computer-readable storage medium, and computer program product provided by the present invention also solve corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0036] Figure 1 A schematic flow chart of a first embodiment of a method for calculating and displaying the shortest distance between three-dimensional model objects according to an embodiment of the present invention;

[0037] Figure 2A schematic diagram of two three-dimensional model objects in a method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0038] Figure 3 This is a schematic diagram of a first distance calculation range in the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0039] Figure 4 A second schematic diagram of a distance calculation range in the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0040] Figure 5 A third schematic diagram of a distance calculation range in the method for calculating and displaying the shortest distance between three-dimensional model objects according to an embodiment of the present invention;

[0041] Figure 6 A schematic diagram showing the shortest distance calculated in the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0042] Figure 7 A schematic flow chart of a second embodiment of a method for calculating and displaying the shortest distance between three-dimensional model objects according to an embodiment of the present invention;

[0043] Figure 8 A schematic diagram of a range sphere of a method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0044] Figure 9 2 is a flow chart of a third embodiment of a method for calculating and displaying the shortest distance between three-dimensional model objects according to an embodiment of the present invention;

[0045] Figure 10 Another schematic diagram of a range sphere of the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0046] Figure 11 A schematic diagram of an embodiment of a device for calculating and displaying the shortest distance between three-dimensional model objects according to an embodiment of the present invention;

[0047] Figure 12 A schematic diagram of an embodiment of a device for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention;

[0048] Figure 13 The figure is a schematic diagram of the principle of a computer-readable medium in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] Exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in various forms, and it should not be understood that the present invention is limited to the embodiments set forth herein. On the contrary, providing these exemplary embodiments enables the present invention to be more comprehensive and complete, making it easier to fully convey the inventive concept to those skilled in the art. In the figures, the same reference numerals represent the same or similar elements, components or parts, and thus their repeated description will be omitted.

[0050] Under the premise of being consistent with the technical concept of the present invention, the features, structures, characteristics or other details described in a specific embodiment do not exclude that they can be combined in one or more other embodiments in a suitable manner.

[0051] In the description of specific embodiments, the features, structures, characteristics, or other details of the present invention are described to enable those skilled in the art to fully understand the embodiments. However, this does not preclude those skilled in the art from practicing the technical solutions of the present invention without one or more of the specific features, structures, characteristics, or other details.

[0052] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.

[0053] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0054] The term "and / or" or "and / or" includes all combinations of any one or more of the associated listed items.

[0055] See also Figures 1-6 The following is a first embodiment of a method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention.

[0056] S101, generating bounding boxes for the first object model and the second object model respectively, connecting the center points of the two bounding boxes to generate a model center connecting line segment, and generating a distance calculation range based on the model center connecting line segment;

[0057] It is understood that the execution subject of the present invention can be a device for calculating and displaying the shortest distance between three-dimensional model objects, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.

[0058] After receiving the shortest distance calculation request, the server first determines the information of the two 3D model objects, namely the first object model and the second object model, for which the shortest distance needs to be calculated and displayed. After obtaining the information of the first object model and the second object model, the server first generates the bounding boxes of the first object model and the second object model; wherein, the bounding boxes can be AABB bounding boxes (Axis-aligned bounding box, Sphere), OBB bounding box (Oriented bounding box, Minimum Enclosing Rectangular Bounding Box), or other bounding boxes.

[0059] In a specific embodiment, the bounding box is an OBB bounding box, see Figure 2 , the bounding box of the generated first object model is as follows Figure 2 As shown in A, the bounding box of the generated second object model Figure 2 As shown in B.

[0060] After generating the bounding boxes of the first object model and the second object model respectively, the center points of the two bounding boxes are obtained, and the coordinates of the center points of the two bounding boxes in the same spatial coordinate system are obtained; the model center connecting line segment of the two bounding box center points is connected, and the position information of the model center connecting line segment can be uniquely determined at this time; and the line segment length of the model center connecting line segment can be calculated based on the coordinates of the center points of the two bounding boxes in the same spatial coordinate system.

[0061] After obtaining the model center connecting line segments, a distance calculation range is generated based on the positions of the model center connecting line segments. Specifically, the distance calculation range is generated based on the model center connecting line segments because the model center connecting line segments indicate the approximate direction of the closest points between the two object models. Therefore, a rough distance calculation range is generated based on the model center connecting line segments, and only the shortest distance between points of the two object models that fall within the distance calculation range is considered. The actual shortest distance is highly likely to fall within the distance calculation range, so discarding points that are not included in the distance calculation range can reduce the amount of calculation to a certain extent and increase the speed of finding the shortest distance.

[0062] In the specific implementation, please refer to Figure 3-Figure 5 The shape of the distance calculation range is not specifically limited and can be as follows Figure 3As shown in , the model center connecting line segment is used as the line connecting the center points of a pair of parallel surfaces of the rectangular cube, and the range enclosed by the generated rectangular cube is used as the distance calculation range; it can also be as shown in Figure 4 As shown in , the model center connecting line segment is used as the cross-sectional diameter of the cylinder center, and the range enclosed by the generated cylinder is used as the distance calculation range; it can also be as shown in Figure 5 As shown in , a sphere is constructed with the line segment connecting the center of the model as the diameter and the center point of the line segment connecting the center of the model as the center. The range enclosed by the generated sphere is used as the distance calculation range. The specific method of dividing the distance calculation range is not limited here.

[0063] S102, filtering out vertices that overlap with the distance calculation range in the first object model and the second object model respectively, to obtain a first vertex data set and a second vertex data set;

[0064] After obtaining the distance calculation range, based on the spatial position information of the distance calculation range, the spatial points included in the first object model and the second object model are obtained to obtain the first vertex data set and the second vertex data set respectively.

[0065] In a specific embodiment, when acquiring the first vertex dataset and the second vertex dataset, the filtered spatial points included in the distance calculation range only include spatial points on the surfaces of the first object model and the second object model.

[0066] S103. Select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a vertex pair with the shortest spatial distance among the vertex pairs as target vertices, and display the shortest distance position between the first object model and the second object model based on the target vertices.

[0067] After obtaining the first and second vertex datasets, vertices are selected from each of the first and second vertex datasets. Vertices can be selected using direct traversal or random selection using a random algorithm. The selected vertices are grouped into vertex pairs from different object models, and the spatial distance between the vertex pairs is calculated.

[0068] After obtaining the spatial distances between each vertex pair, a vertex pair with the shortest spatial distance is selected as the target vertex, and the spatial distance between the target vertices is used as the shortest distance between the first object model and the second object model.

[0069] In a specific embodiment, see Figure 6 As shown in the middle line segment D, a connecting line is generated based on the spatial position of the target vertex, showing the shortest distance position and the shortest distance value between the first object model and the second object model.

[0070] The method for calculating and displaying the shortest distance position between three-dimensional model objects provided in an embodiment of the present invention generates a distance calculation range based on the line connecting the centers of the bounding boxes of the first object model and the second object model, and only selects the spatial points of the two object models in the distance calculation range to calculate the shortest distance, generate and display the shortest distance position, which can reduce the spatial point position data that needs to be obtained when calculating the shortest distance, and can improve the efficiency of calculating and displaying the shortest distance between three-dimensional model objects.

[0071] Please see Figure 7 as well as Figure 8 The following is a second embodiment of the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention.

[0072] S201, generating bounding boxes for the first object model and the second object model respectively, and connecting the center points of the two bounding boxes to generate a model center connecting line segment;

[0073] The content of step S201 in this embodiment is substantially the same as the method of generating the bounding boxes of the first object model and the second object model and obtaining the connecting line segments of the model centers in step S101 in the aforementioned embodiment, and therefore will not be described in detail here.

[0074] Specifically, in this embodiment, the bounding box is a minimum circumscribed rectangular bounding box of an OBB bounding box.

[0075] S202: Based on the length of the line segment connecting the model center as the range sphere diameter, a range sphere is drawn with the midpoint of the line segment connecting the model center as the sphere center to obtain a distance calculation range;

[0076] See also Figure 8 In this embodiment, the distance calculation range is obtained by making a range sphere based on the line segment connecting the center of the model. Specifically, the length of the line segment connecting the center of the model is used as the range sphere diameter L1, and the midpoint of the line segment connecting the center of the model is used as the sphere center O to make a range sphere S1 to obtain the distance calculation range.

[0077] S203, filtering out vertices that overlap with the distance calculation range in the first object model and the second object model respectively, to obtain a first vertex data set and a second vertex data set;

[0078] The content of step S203 in this embodiment is substantially the same as that of step S102 in the aforementioned embodiment, and thus will not be described in detail here.

[0079] S204. Select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a vertex pair with the shortest spatial distance among the vertex pairs as target vertices, and display the shortest distance position between the first object model and the second object model based on the target vertices.

[0080] After obtaining the first vertex data set and the second vertex data set, vertices are selected from the first vertex data set and the second vertex data set respectively, thereby obtaining multiple vertex pairs from different object models; in this embodiment, the vertices can be selected using a random algorithm.

[0081] In a specific embodiment, a coding sorting rule can be set in advance, and according to the coding sorting rule, the vertices of the first vertex data set and the second vertex data set are sorted and numbered respectively; a pseudo-random algorithm is used to randomly generate multiple first random numbers and multiple second random numbers to obtain multiple random number pairs; the vertex corresponding to the first random number in the first vertex data set is obtained according to the vertex number, and the vertex corresponding to the second random number in the second vertex data set is obtained according to the vertex number, to obtain multiple vertex pairs from different object models; the coordinate information of the multiple vertex pairs is obtained and the point pair distance is calculated, and a pair of vertex pairs with the shortest point pair distance is selected as the target vertex pair.

[0082] Furthermore, in a specific embodiment, the encoding sorting rule can be to arrange the three-dimensional coordinates of each vertex in ascending order according to the x, y, and z values. The purpose of this is to ensure that the vertices collected using range sphere filtering are the same under the same device and the same distance conditions, and the vertex sequence can be kept consistent each time.

[0083] When randomly selecting vertices, the random algorithm seed is initialized, and two numbers are generated each time using a pseudo-random algorithm. This pseudo-random algorithm ensures that the random numbers generated the same number of times are identical. Each number corresponds to a vertex in objects A and B that participate in the calculation. Since the vertices selected for the shortest distance calculation in objects A and B are already sorted, the two random numbers each time can be mapped to the subscript of their array sequence. The subscript value of the array sequence can be calculated using a modulo operation (Modulo).

[0084] In a specific embodiment, when using a random algorithm to select vertices, the vertices of each object in the range sphere can be used as points participating in the nearest distance calculation, and each pair of vertices can be sorted by coordinates (x, y, z) using Morton code, and then selected from their respective sequences or blocks, and the distance length between the vertex pairs can be calculated.

[0085] In a specific embodiment, before randomly selecting and generating vertex pairs, a vertex pair quantity threshold is pre-set. After the number of generated vertex pairs exceeds the threshold, selection is stopped and the shortest distance among the already selected vertex pairs is selected as the target vertex pair.

[0086] The method for calculating and displaying the shortest distance position between three-dimensional model objects provided in an embodiment of the present invention generates a distance calculation range based on the line connecting the centers of the bounding boxes of the first object model and the second object model, and only selects the spatial points of the two object models in the distance calculation range to calculate the shortest distance, generate and display the shortest distance position, which can reduce the spatial point position data that needs to be obtained when calculating the shortest distance, and can improve the efficiency of calculating and displaying the shortest distance between three-dimensional model objects.

[0087] Please see Figure 9-10 The following is a third embodiment of the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention.

[0088] S301, generating bounding boxes for the first object model and the second object model respectively, and connecting the center points of the two bounding boxes to generate a model center connecting line segment;

[0089] The content of step S201 in this embodiment is substantially the same as the method of generating the bounding boxes of the first object model and the second object model and obtaining the connecting line segments of the model centers in step S101 in the aforementioned embodiment, and therefore will not be described in detail here.

[0090] Specifically, in this embodiment, the bounding box is a minimum circumscribed rectangular bounding box of an OBB bounding box.

[0091] S302, determining a first enclosing ratio and a second enclosing ratio;

[0092] In this embodiment, not just one distance calculation range is generated, but two distance calculation ranges are generated for each of the two object models. Taking the second embodiment of the aforementioned method as an example, if only one calculation range is used, when one object is larger than the other, the larger object will have more vertices enclosed by the distance calculation range, while the smaller object will have fewer vertices, resulting in inaccurate calculations. Therefore, in this embodiment, two distance calculation ranges are generated by determining a first enclosing ratio and a second enclosing ratio to improve the accuracy of the shortest distance calculation display for two object models of significantly different sizes.

[0093] In a specific implementation of this embodiment, the distance calculation range generated is similar to that in the second embodiment of the aforementioned method, both generating range spheres. However, a first enclosing ratio and a second enclosing ratio are first determined, and two range spheres of different sizes are generated based on the first and second enclosing ratios. Specifically, based on the object's volume, a smaller collision sphere is generated for a larger object model, and a larger collision sphere is generated for a smaller object model. In this case, in this embodiment, the distance calculation range includes the first and second distance calculation ranges, the range spheres include the first and second range spheres, and the range sphere diameters include the first and second range sphere diameters.

[0094] In a specific embodiment, when determining the first enclosing ratio and the second enclosing ratio, the first enclosing ratio and the second enclosing ratio can be determined based on the ratio of the bounding box sizes of the first object model and the second object model, or the first enclosing ratio and the second enclosing ratio can be determined based on the ratio of the actual volume sizes of the first object model and the second object model, or the first enclosing ratio and the second enclosing ratio can be determined based on the ratio of the actual number of vertices of the first object model and the second object model.

[0095] S303, calculating the first range sphere diameter and the second range sphere diameter respectively according to the length of the connecting line segment of the model center, the first enclosing ratio and the second enclosing ratio;

[0096] See also Figure 10 After obtaining the first and second enclosing ratios, the first and second range sphere diameters can be calculated based on the first and second enclosing ratios and the length of the line segment connecting the model center. In a specific example, the first and second enclosing ratios are represented by λ1 and λ2, respectively. L2 is obtained by multiplying the first enclosing ratio λ1 by the length of the line segment connecting the model center; L3 is obtained by multiplying the first enclosing ratio λ2 by the length of the line segment connecting the model center; where the valid range of λ1 and λ2 is (0,1). Subsequently, L2 is used as the first range sphere diameter, and L3 is used as the second range sphere diameter.

[0097] S304, using the midpoint of the line segment as the sphere center, and using the first range sphere diameter and the second range sphere diameter as the first range sphere diameter and the second range sphere diameter to form the first range sphere and the second range sphere, respectively, to obtain the first distance calculation range and the second distance calculation range;

[0098] The midpoint O of the line segment is used as the sphere center, and the first range sphere diameter L2 and the second range sphere diameter L3 are used as the first range sphere S2 and the second range sphere S3 respectively, and the ranges contained in the first range sphere S2 and the second range sphere S3 are used as the first distance calculation range and the second distance calculation range.

[0099] S305 , screening out vertices that coincide with the first distance calculation range in the first object model to obtain a first vertex data set;

[0100] S306 , screening out vertices that coincide with the second distance calculation range in the second object model to obtain a first vertex data set;

[0101] After obtaining the first distance calculation range and the second distance calculation range, the vertices that overlap with the first distance calculation range are screened out in the first object model A, that is, the vertices that overlap with the first range sphere S2 of the first object model A are screened out to obtain a first vertex data set; the vertices that overlap with the second distance calculation range are screened out in the second object model B, that is, the vertices that overlap with the second range sphere S3 of the second object model B are screened out to obtain a second vertex data set; in this way, a larger distance calculation range is used to screen vertices in an object model with a smaller volume, and a smaller distance calculation range is used to screen vertices in an object model with a larger volume, thereby avoiding a situation where the number of vertices included in the first vertex data set and the second vertex data set differ too much.

[0102] S307. Select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a vertex pair with the shortest spatial distance among the vertex pairs as the target vertex, and display the shortest distance position between the first object model and the second object model based on the target vertex.

[0103] The content of step S307 in this embodiment is substantially the same as that of step S204 in the aforementioned embodiment, and thus will not be described in detail here.

[0104] The method for calculating and displaying the shortest distance position between three-dimensional model objects provided in an embodiment of the present invention generates a distance calculation range based on the line connecting the centers of the bounding boxes of the first object model and the second object model, and only selects the spatial points of the two object models in the distance calculation range to calculate the shortest distance, generate and display the shortest distance position, which can reduce the spatial point position data that needs to be obtained when calculating the shortest distance; and when generating the calculation range and the spatial points in the acquisition range, adjustments are made according to the volume sizes of the two objects, and different acquisition ranges are generated respectively, which further improves the efficiency of calculating and displaying the shortest distance between three-dimensional model objects, and to a certain extent prevents the situation where the accuracy of the shortest distance calculation is insufficient.

[0105] The above describes the method for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention. The following describes the device for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention. Figure 11 An embodiment of the shortest distance position device between three-dimensional model objects in an embodiment of the present invention includes:

[0106] Range acquisition module 401, configured to generate bounding boxes for the first object model and the second object model respectively, connect the center points of the two bounding boxes to generate a model center connecting line segment, and generate a distance calculation range based on the model center connecting line segment;

[0107] a vertex screening module 402 for screening out vertices that overlap with the distance calculation range in the first object model and the second object model, respectively, to obtain a first vertex data set and a second vertex data set;

[0108] The distance calculation module 403 is used to select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a pair of vertex pairs with the shortest spatial distance as the target vertex, and display the shortest distance position between the first object model and the second object model based on the target vertex.

[0109] The method for calculating and displaying the shortest distance position between three-dimensional model objects provided in an embodiment of the present invention generates a distance calculation range based on the line connecting the centers of the bounding boxes of the first object model and the second object model, and only selects the spatial points of the two object models in the distance calculation range to calculate the shortest distance, generate and display the shortest distance position, which can reduce the spatial point position data that needs to be obtained when calculating the shortest distance, and can improve the efficiency of calculating and displaying the shortest distance between three-dimensional model objects.

[0110] In another embodiment of the present application, the range acquisition module 401 is specifically configured to:

[0111] Based on the length of the line segment connecting the center of the model as the range sphere diameter, a range sphere is drawn with the midpoint of the line segment connecting the center of the model as the sphere center to obtain the distance calculation range.

[0112] In another embodiment of the present application, the distance calculation range includes a first distance calculation range and a second distance calculation range, the range sphere includes a first range sphere and a second range sphere, and the range sphere diameter includes a first range sphere diameter and a second range sphere diameter;

[0113] The range acquisition module 401 is further specifically configured to:

[0114] determining a first enclosing ratio and a second enclosing ratio;

[0115] Calculate a first range sphere diameter and a second range sphere diameter respectively according to the length of the connecting line segment of the model center, the first enclosing ratio, and the second enclosing ratio;

[0116] The midpoint of the line segment is used as the sphere center, and the first range sphere diameter and the second range sphere diameter are used as the first range sphere diameter and the second range sphere diameter respectively to obtain the first distance calculation range and the second distance calculation range.

[0117] In another embodiment of the present application, the vertex screening module 402 is further configured to:

[0118] Screening out vertices that coincide with the first distance calculation range in the first object model to obtain a first vertex data set;

[0119] Vertices that coincide with the second distance calculation range are screened out in the second object model to obtain a first vertex data set.

[0120] In another embodiment of the present application, the distance calculation module 403 is further configured to:

[0121] According to the coding sorting rule, sorting and numbering the vertices of the first vertex data set and the second vertex data set respectively;

[0122] randomly generating a plurality of first random numbers and a plurality of second random numbers using a pseudo-random algorithm to obtain a plurality of random number pairs;

[0123] Obtaining a vertex corresponding to the first random number in the first vertex data set according to the vertex number; obtaining a vertex corresponding to the second random number in the second vertex data set according to the vertex number, to obtain a plurality of vertex pairs from different object models;

[0124] The coordinate information of the plurality of vertex pairs is obtained and the distance between the vertex pairs is calculated, and a vertex pair with the shortest distance between the vertex pairs is selected as the target vertex.

[0125] In another embodiment of the present application, the bounding box is a minimum circumscribed rectangular bounding box.

[0126] In addition, the specific implementation method performed by the device for calculating and displaying the shortest distance between three-dimensional model objects provided in the embodiment of the present invention during operation can be found in the specific content of the aforementioned method embodiment, and will not be repeated here.

[0127] The device for calculating and displaying the shortest distance position between three-dimensional model objects provided in an embodiment of the present invention generates a distance calculation range based on the line connecting the centers of the bounding boxes of the first object model and the second object model, and only selects the spatial points of the two object models in the distance calculation range to calculate the shortest distance, generate and display the shortest distance position, which can reduce the spatial point position data that needs to be obtained when calculating the shortest distance, and can improve the efficiency of calculating and displaying the shortest distance between three-dimensional model objects.

[0128] Based on the same inventive concept, an embodiment of this specification also provides an electronic device for calculating and displaying the shortest distance between three-dimensional model objects. The electronic device for calculating and displaying the shortest distance between three-dimensional model objects in an embodiment of the present invention is described in detail below from the perspective of hardware processing.

[0129] Figure 12 This is a schematic diagram of the structure of an electronic device provided in the embodiment of this specification. Figure 12 The electronic device 500 according to this embodiment of the present invention will be described. Figure 12 The electronic device 500 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present invention.

[0130] like Figure 12 As shown, electronic device 500 is implemented as a general-purpose computing device. Components of electronic device 500 may include, but are not limited to, at least one processing unit 510, at least one storage unit 520, a bus 530 connecting various system components (including storage unit 520 and processing unit 510), a display unit 540, and the like.

[0131] The storage unit stores program codes, which can be executed by the processing unit 510, so that the processing unit 510 performs the steps according to various exemplary embodiments of the present invention described in the above processing method section of this specification. For example, the processing unit 510 can perform the following steps: Figure 1 、 Figure 7 or Figure 9 Steps shown.

[0132] The storage unit 520 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 5201 and / or a cache memory unit 5202 , and may further include a read-only memory unit (ROM) 5203 .

[0133] The storage unit 520 may also include a program / utility 5204 having a set (at least one) of program modules 5205, such program modules 5205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.

[0134] Bus 530 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0135] The electronic device 500 may also communicate with one or more external devices 100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 550. Furthermore, the electronic device 500 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 560. The network adapter 560 may communicate with other modules of the electronic device 500 through the bus 530. It should be understood that although Figure 12 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 500, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0136] In addition, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the method for calculating and displaying the shortest distance position between three-dimensional model objects as described in any of the above embodiments.

[0137] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the exemplary embodiments described in the present invention can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the present invention. When the computer program is executed by a data processing device, the computer-readable medium can implement the above method of the present invention based on the execution of the computer program / instructions, that is: Figure 1 、 Figure 7 or Figure 9 The method shown.

[0138] Figure 13 A schematic diagram of a computer-readable medium provided in accordance with an embodiment of this specification.

[0139] accomplish Figure 1 、 Figure 7 or Figure 9The computer program of the method shown can be stored on one or more computer-readable media. The computer-readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0140] The computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. The data signal propagated may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or component. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.

[0141] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0142] In summary, the present invention can be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that general data processing equipment such as a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing a part or all of the methods described herein. Such a program for implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0143] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the present invention is not inherently related to any specific computer, virtual device, or electronic device, and various general-purpose devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.

[0144] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.

[0145] If the technical solution of this application involves personal information, the product that applies the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing personal information. If the technical solution of this application involves sensitive personal information, the product that applies the technical solution of this application has obtained the individual's separate consent before processing sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, a clear and prominent sign is set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that they agree to the collection of their personal information; or on the personal information processing device, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload their personal information; among which, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0146] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for calculating and displaying the shortest distance between three-dimensional model objects, characterized in that: include: Generating bounding boxes for the first object model and the second object model respectively, connecting the center points of the two bounding boxes to generate a model center connecting line segment, and generating a distance calculation range based on the model center connecting line segment; Filtering out vertices that overlap with the distance calculation range in the first object model and the second object model respectively to obtain a first vertex data set and a second vertex data set; Vertices are selected from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, a pair of vertex pairs with the shortest spatial distance among the vertex pairs is selected as the target vertex, and the shortest distance position between the first object model and the second object model is displayed based on the target vertex.

2. The method for calculating and displaying the shortest distance between three-dimensional model objects according to claim 1, characterized in that: Generating a distance calculation range based on the model center connecting line segments includes: Based on the length of the line segment connecting the center of the model as the range sphere diameter, a range sphere is drawn with the midpoint of the line segment connecting the center of the model as the sphere center to obtain the distance calculation range.

3. The method for calculating and displaying the shortest distance between three-dimensional model objects according to claim 1, wherein: The distance calculation range includes a first distance calculation range and a second distance calculation range, the range sphere includes a first range sphere and a second range sphere, and the range sphere diameter includes a first range sphere diameter and a second range sphere diameter; Generating a distance calculation range based on the model center connecting line segments includes: determining a first enclosing ratio and a second enclosing ratio; Calculate a first range sphere diameter and a second range sphere diameter respectively according to the length of the connecting line segment of the model center, the first enclosing ratio, and the second enclosing ratio; The midpoint of the line segment is used as the sphere center, and the first range sphere diameter and the second range sphere diameter are used as the first range sphere diameter and the second range sphere diameter respectively to obtain the first distance calculation range and the second distance calculation range.

4. The method for calculating and displaying the shortest distance between three-dimensional model objects according to claim 3, wherein: The step of respectively selecting vertices that overlap with the distance calculation range from the first object model and the second object model to obtain a first vertex data set and a second vertex data set includes: Screening out vertices that coincide with the first distance calculation range in the first object model to obtain a first vertex data set; Vertices that coincide with the second distance calculation range are screened out in the second object model to obtain a first vertex data set.

5. The method for calculating and displaying the shortest distance between three-dimensional model objects according to any one of claims 1 to 4, characterized in that: The selecting vertices from the first vertex data set and the second vertex data set respectively to obtain a plurality of vertex pairs from different object models, and selecting a vertex pair with the shortest spatial distance among the vertex pairs as the target vertex comprises: According to the coding sorting rule, sorting and numbering the vertices of the first vertex data set and the second vertex data set respectively; randomly generating a plurality of first random numbers and a plurality of second random numbers using a pseudo-random algorithm to obtain a plurality of random number pairs; Obtaining a vertex corresponding to the first random number in the first vertex data set according to the vertex number; obtaining a vertex corresponding to the second random number in the second vertex data set according to the vertex number, to obtain a plurality of vertex pairs from different object models; The coordinate information of the plurality of vertex pairs is obtained and the distance between the vertex pairs is calculated, and a vertex pair with the shortest distance between the vertex pairs is selected as the target vertex.

6. The method for calculating and displaying the shortest distance between three-dimensional model objects according to claim 5, characterized in that: The bounding box is a minimum circumscribed rectangular bounding box.

7. A device for calculating and displaying the shortest distance between three-dimensional model objects, characterized in that: include: a range acquisition module, configured to generate bounding boxes for the first object model and the second object model, respectively, connect the center points of the two bounding boxes to generate a model center connecting line segment, and generate a distance calculation range based on the model center connecting line segment; a vertex screening module, configured to screen out vertices overlapping with the distance calculation range in the first object model and the second object model respectively, to obtain a first vertex data set and a second vertex data set; A distance calculation module is used to select vertices from the first vertex data set and the second vertex data set respectively to obtain multiple vertex pairs from different object models, select a pair of vertex pairs with the shortest spatial distance as the target vertex, and display the shortest distance position between the first object model and the second object model based on the target vertex.

8. A device for calculating and displaying the shortest distance between three-dimensional model objects, characterized in that: The device for calculating and displaying the shortest distance between three-dimensional model objects includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor calls the instructions in the memory to enable the device for calculating and displaying the shortest distance between three-dimensional model objects to perform the steps of the method for calculating and displaying the shortest distance between three-dimensional model objects according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the program / instruction is executed by a processor, the steps of the method for calculating and displaying the shortest distance between three-dimensional model objects as described in any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method for calculating and displaying the shortest distance between three-dimensional model objects according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Rapid calculation method of minimum distance between object surfaces in virtual reality simulation

    CN104462764A

  • Method of resolving shortest distance between any two polyhedrons in three-dimensional space

    CN108875936A

  • Spatial feature extracting and matching method and device for three-dimension models

    CN108921045A

  • Method and device for obtaining parallel nearest distance between entity models

    CN112802201A

  • Collision detection method and device for model

    CN118674876A