Abstract
With the rapid development of the technologies of virtual reality (VR) and augmented reality (AR), the accurate visual query of 3D objects which are closer to real world has become a hotspot of study. There are a lot of redundancy problems in the existing axisaligned bounding box model (AABB) and oriented bounding box model (OBB), which are used to represent 3D objects mostly at present, and cannot be used for the accurate visual query. For example, the results of the visual query must be accurate, and without any error in automatic driving technology in the automotive industry, otherwise, serious safety problems would be caused. The convex hull model could be used to solve those problems. However, there are few studies on visual query based on the convex hull model. A visual query method for 3D obstacle space based on the convex hull model is proposed in this paper. Firstly, the definitions of “query pointobject visual body” and “combined obstacle” are proposed. Secondly, the visibility detection algorithm of the convex hull model is given in detail. The collision detection method of “query pointobject visible body” combined with other obstacles and lineplane geometric calculation operations are used to detect the visibility of the convex hull model. Then, a 3D visual knearest neighbor algorithm based on the convex hull model is given in the paper. Finally, the algorithm is verified by experiments and compared with the traditional visibility detection algorithm, and the analysis of experimental results shows that the algorithm has a great performance and higher accuracy. The growth rate of the query time is smaller, and the speed is faster; especially, when there are fewer query points, the query speed can be increased by more than 50%.
1. Introduction
In recent years, with the rapid development of computer graphics, humancomputer interaction technology, sensor technology, and network technology, and VR and AR technology have been developed rapidly and used widely in various fields. For example, in the medical field, virtual human organ models [1] with the same proportions of real people can improve the pertinence and effectiveness of doctors’ training, which could improve the accuracy of surgical, and eliminate the risk of being blamed morally for repetitive practice on real people. In addition, it is used in mechanical surgery to achieve accurate tumor resection. In the military field, VR can also be used to train military personnel to explore and learn new skills. The US. Department of Defense has developed multiple virtual battlefield systems [2], which can realize exercises that multiple people work together in virtual space, precision strikes, and radar detection of fighter jets can be achieved. In the aerospace field, NASA has developed a VR system to improve the proficiency of astronauts participating in missions in outer space [3]. In the automotive industry, the application of autonomous driving technology can enable cars to avoid obstacles during autonomous driving and find the optimal driving path. All of the above belong to the research of visual query in threedimensional obstacle space. In VR applications, invisible spatial objects are invalid data for the users. Based on this principle, the visual query in threedimensional obstacle space is a research content with high academic and commercial value. However, there are still scarce studies in this field.
Visual query is a kind of query in obstacle space, and it faces unique problems in threedimensional space, for example, the problem of building a 3D space object model. At present, some achievements have been made in the research of spatial database in twodimensional space, such as storage and index structure of objects and obstacles, prediction and storage of viewable fields, visibility detection of object, and calculation of visual subinterval in continuous visual query. However, the research on visual query of threedimensional objects is just emerging. Different from the general query in obstacle space, it is closer to the real world. While the objects in the threedimensional space have the characteristics of uneven distribution density, irregular shape, and a large amount of the data, for the visibility detection of the real 3D objects, the traditional double projection method cannot be used as the detection of AABB bounding box, nor the detection method of “based on horizontal projection angle curve” which is projected to the horizontal plane and vertical plane like the detection of OBB bounding box [4]. The object model is arbitrary and close to reality in threedimensional space, which will lead to the lack of a unified projection plane among the query objects, data objects, and obstacle objects, and the visual relationship cannot be represented correctly in the projection by the positions of the three types of objects. In order to solve these problems, a visual query method based on the convex hull model in threedimensional obstacle space is proposed, which fills the gap of current research by enabling accurate query of objects when multiple obstacles combine together to block the visible area. It has important value in the automation industry.
Compared with the existing studies, the contributions of our research are highlighted as follows: firstly, the GJK collision algorithm, which is introduced in Section 3.1, is used to detect the visibility of the threedimensional space, which can filter out a lot of objects and improve the efficiency of the algorithm. Secondly, according to the complex situation of obstacles in threedimensional space, the obstacles that collide with each other are combined to form combined obstacles, and the visual detection algorithm is performed. Finally, the real threedimensional space is simulated, and the knearest neighbor query algorithm is proposed. Due to the convex hull model, the query accuracy is higher, and the query speed is faster than the traditional methods in 3D obstacle space.
The structure of the paper is as follows: in Section 1, an overall introduction and the significance of the research are described. In Section 2, a brief summary of related work is given. In Section 3, some definitions, such as “query pointobject visual body” and “combined obstacles”, and related theorems are given. In Section 4, a detailed introduction and description of the visibility detection algorithm are given. In Section 5, the visual knearest neighbor query algorithm based on a convex hull is introduced in detail. In Section 6, the experimental environment is set up, and an experimental comparison is made to prove that the query algorithm has a good performance.
2. Related Works
There had been a lot of research on the visibility detection of threedimensional objects, and some progress had been made. In 2017, Alipour et al. [5] studied the visibility counting problem (VCP) and visibility testing problem (VTP) of data in a 2.5D terrain environment and gave an approximate algorithm for visibility calculation and detection, which reduced the computing cost. Chen and Wang [6] studied the calculation of weak visibility between line segments in simple polygons. Zarei and Ghodsi [7] proposed a method to solve the problem of query point visibility computation in polygons with holes. Ghodsi et al. [8] gave a method of αvisibility based on the concept of α that could be applied to weak visual detection between point and line segment and between line segment and line segment. Arkin [9] obtained the shortest path from point S to the query point q within the time of O(Klog^{2}n) by using a data structure in which time complexity was O(n^{2}2a^{(n)}logn), a(n) was the inverse Ackermann function, and K was the number of query points. Wang H [10] proposed a new algorithm for the shortest path segmentation query problem to optimize the query result of the visibility of the polygon area and use the data structure in which time complexity of construction was O(nlogh + h^{2}) and query time was O(hloghlogn). When h was small relatively, the overall performance improved greatly. The visual query researches mentioned aboverequired precalculation of the visual area, which could not meet many requirements of the practical applications.
Therefore, extensive and indepth researches that did not require precalculation had been conducted on visibility queries. Shou et al. [11] proposed an HDoV tree to improve the performance and visual fidelity of the visualization system. Kofler et al. [12] combined Rtree and LOD and proposed a LODR tree index structure that could handle large amounts of data effectively. Zhang et al. [13] discussed the problems of spatial query processing when obstacles existed and proposed an integrated framework that could solve these problems effectively. Gao et al. [14] proposed a new query algorithm for the reverse visual knearest neighbor query to deal with the visibility problems of the reverse knearest neighbor query in twodimensional space. Yu et al. proposed a reverse knearest neighbor query method in obstacle space [15] and proposed a continuous reverse knearest neighbor query subsequently based on controlled points [16]. These methods were still not suitable for visual query in threedimensional space. Zhang et al. [17] combined the characteristics of the Voronoi diagram and the corresponding pruning algorithm to optimize the group reverse k nearest neighbor query and proposed the V_GRkNN algorithm. Song et al. [18] proposed the SOS algorithm and the ADD_SOS algorithm to solve the skyline query problem in the obstacle space. In addition, the research on the visual query of moving objects was also an important branch of visual queries. Yu et al. [19] proposed a DSI index structure that could process kNN queries in a distributed manner. Han et al. [20] proposed a new GRI framework and HGTPR tree index structure for the problem that moving objects on the urban road often changed, and it was not easy to track and query. The studies above were more suitable for centralized data processing. Cho et al. [21] proposed a distributed expansion scheme of DAEMON, which could be used for CkNN query in the road network. Vorona et al. [22] proposed an approximate geospatial query processing engine based on deep learning, which could respond to flexible aggregation queries, but the study did not consider the issue of visibility. Wan et al. [23] proposed a COPkNN query to solve the continuous knearest neighbor query problem of moving objects. Li et al. [24] studied the query algorithm of indoor obstacle space for the problem of moving objects affecting each other’s deformation properties and proposed the DSPTopk query algorithm. Compared with the existing Topk algorithm, it was only suitable for a small number of target objects. Yu et al. [25] proposed a query method based on a moving window to search random trees quickly and dealt with the problems of path planning in obstacle spaces. Luo et al. [26] studied the visual nearest neighbor query of moving objects on continuous trajectories.
The studies mentioned above were in the twodimensional space, and their results could not be applied directly to the threedimensional visual query. The visibility detection method of objects and the calculation of obstacle distance in threedimensional space were more complicated than those in twodimensional space. Arman et al. [27] proposed an efficient and scalable interactive system VizQ to deal with the visibility query problem in the threedimensional obstacle space. However, the system was based on the AABB model, which had a low reliability of the visibility detection algorithm. In addition, some scholars studied moving objects in 3D visual queries. Haider et al. [28] studied the methods of finding out the best viewpoint continuously from a set of candidate viewpoints and proposed a kcontinuous maximum visibility query algorithm (kCMN), which could provide the best line of sight for moving objects in 2D or 3D obstacle space. Rabban et al. [29] designed an effective graph theory method for the maximum visibility facility selection query (MVFS), which solved the discrete space problem, but did not support the applications of the new database. The idea of vertex separators was used to design an effective graph theory method. A large number of obstacles and facility locations were expanded. With the continuous development of geographic information systems, a 3D spatial data model was used to solve data problems collected by visualization tools, such as mechanical properties of rock mass [30], heterogeneous slopes [31], elastic properties of rock materials, and plastic yield stress problem [32], and the distribution of particulate material between gaps [33]. New applied models had also been created to address these practical problems, 3D multiphase mesomodels for the case where concrete damage and transport properties were coupled [34]. Contact detection algorithms based on Minkowski differences are applied to convex polygon/polyhedron discretization/in discontinuous modeling [35]. This method did not consider the presence of concave bodies. Meng Qingxiang proposed a threedimensional mesoscale computational model of concave granular soilrock mixtures [36] and conducted research on concave bodies in 3D space. The calculation method was complex and suitable for processing a small number of objects.
In summary, many data models and research methods had been proposed according to practical problems. However, the methods mentioned above were not suitable for accurate query in threedimensional space. At present, the research on the query in threedimensional space is just beginning. Combining the characteristics of the convex hull model and the characteristics of vision space, the visibility detection algorithm and visible knearest neighbor query algorithm are proposed based on the convex hull model.
3. Related Definitions and Theorems
Compared with the traditional threedimensional obstacle space, the main difficulty in the threedimensional obstacle space of this paper is that both the data object and the obstacle object are threedimensional objects represented by the convex hull model, and there is no unified projection plane for them. Therefore, the visibility cannot be detected by the projection method, nor can the detection method “based on the horizontal projection angle curve” be used. In addition, the obstructed areas of the obstacle objects in the threedimensional space are three dimensional, so the viewable area cannot be calculated by the angle like those in the twodimensional space. In this paper, the visibility detection of threedimensional objects is regarded as the detection of the spatial position relationship between the visible objects and the obstacles. The space geometry algorithm of GJK collision detection is used to calculate the spatial position relationship between the data object and the obstacle which are represented by the convex hull model, and the initial shielding relationship is obtained between the query object and the obstacle. Then, we use the linesurface relationship geometry calculation to further detect the visibility of the threedimensional object and complete the visibility detection of the threedimensional object based on the convex hull model.
3.1. Overview of GJK Algorithm
One of the most effective algorithms for the intersecting polyhedrons is an iterative algorithm developed by Gilbert, Johnson, and Keerthi, known as the GJK algorithm for short. The algorithm defines two sets of the vertices and calculates the Euclidean distance between the elements of the sets. It should be emphasized that the GJK algorithm does not perform any substantive operations on the set of input points but calculates the Minkowski differences between the points. The related problem is simplified from calculating the distance between two sets of convex bodies to solving the distance in a single set of convex body. The GJK algorithm searches for the Minkowski difference object and obtains a subspace volume during each iteration of the loop, and the spatial volume is a singular body. In addition, the algorithm does not display the calculation of the Minkowski difference and adopts a sampling calculation for the Minkowski difference according to specific requirements and through a support mapping function. The algorithm is based on the following principle: as shown in Figure 1(a), the distance between the two polyhedrons A and B is equivalent to the distance between the Minkowski difference C(C = AθB) and the origin, as shown in Figure 1(b). Therefore, the problem is simplified to solve the nearest point on C from the origin. The explicit calculation of the Minkowski difference is quite complicated. GJK algorithm adopts the method of sampling the vertex set of the Minkowski difference through the support mapping function C = AθB to simplify the operation. In particular, the support function S_{A}(d) maps the given direction d to a certain support point in the convex object A in that direction. Since the supporting function reflects the maximum value of the linear function, the supporting mapping for C is S_{AθB}(d), where the correlation mapping between A and B can be expressed as S_{AθB}(d) = S_{A}(d)–S_{B}(d). Therefore, the corresponding vertices of the Minkowski difference can be calculated from polyhedron A and B according to the specific requirements.
(a)
(b)
3.2. The Related Definitions
Definition 1. AABB model: AABB is short for axisaligned bounding box model. It is defined as the smallest hexahedron that contains the object and whose sides are parallel to the coordinate axis. The structure of the AABB model is simple relatively, with small storage space, but poor compactness. Especially, for elongated objects placed diagonally, the redundant space is large as shown in Figure 2(a).
(a)
(b)
Definition 2. OBB model: OBB is short for oriented bounding box model. It is the smallest rectangular parallelepiped that contains the object and is relative to the coordinate axis in any direction as shown in Figure 2(b). The spatial redundancy of the OBB model is smaller than the AABB model.
Definition 3. 3D spatial object: the object in 3D space is a polyhedron represented by a 3D convex hull. Each convex hull polyhedron is represented by a List(C), and C=(X, Y, Z) is a coordinate point constituting the surface of the polyhedron as shown in Figure 3.
Definition 4. Shortest distance: the distance between the query point q and the threedimensional object represented by convex hull polyhedron should be considered separately: the distance between q and vertex, q and edge, q and surface. After comparison, the shortest distance is obtained from the query point q to the polyhedron, which can be represented as the shortest distance from the query point to the convex hull, as shown in Figure 4.
Definition 5. Visibility of 3D spatial object: given a query point q, set Obj as an object set in the 3D space and as an obstacle set in the 3D space. If is visible to the query point q, it means that there is at least one point o on the object obj, and the line between o and q does not pass through any obstacle, which means , , [o, q] ∩ = .
Definition 6. Query pointobject visual body: given a query point q, a threedimensional spatial object set Obj and a threedimensional obstacle set Obs, assuming that and the query point q form a threedimensional viewing cone, then the convex hull model regenerated after adding the coordinate point of the point q to the coordinate set of the object obj is called the “query pointobject visual body” as shown in Figure 5.
Definition 7. Combined Obstacle: given a query point q, a threedimensional object obj and a threedimensional obstacle set , assuming , , …, if obs1, obs2, … have a collision relationship, then the smallest outsourcing polyhedron of these obstacles obs1, obs2, … is the “combined obstacle”. As shown in Figure 6, the two obstacles obs1 and obs2 collide, and the smallest outsourcing polyhedron obs12 formed by obs1 and obs2 is the “combined obstacle”.
3.3. The Related Theorems
Theorem 1. Given a threedimensional spatial object set O, a threedimensional obstacle object set and a query point q. For any , , if there is a collision between and the “query pointobject visual body” qo, then there is an occlusion relationship between and o.
Prove: As shown in Figure 7, the query point q and the spatial object o in the threedimensional space formed a “query pointobject visible body” qo, and it collides with an obstacle . There must be a ridge line on the qo passing through the obstacle , which means that a part of the line of sight from the query point q to the spatial object o is projected by the obstacle , the line of sight is blocked, and the obstacle and the object have an occlusion relationship.
Theorem 2. Given a threedimensional object set O, a threedimensional obstacle set and a query point q, for any , , q and o form a “query pointobject visual body” qo, q and form a “query pointobstacle visual body” . If all the outermost edges of qo including the query point q can pass through all the outermost faces on , then obscures o completely, and the query object o is invisible to the query point q.
Proof. The occlusion relationship between the object and the obstacle can be regarded as the positional relationship between the outermost edges of the “query pointobject visible body” qo and the outermost surface Facs of the “query pointobstacle visible body” . As shown in Figure 8, the reason for adopting the outermost edges of qo including the query point q and the outermost outer surface Facs of for detection is that the outermost edges of qo can form the largest visual field of the object o. If the largest field of view of the spatial object based on the query point is occluded completely, the smaller field of view formed by the internal point set must also be occluded completely. There is no need to test the smaller field. If the smaller field of view formed inside is obscured completely, it is not certain whether the entire field of view of the spatial object relative to the query point is obscured. Moreover, the number of smaller internal fields of view is large, the formation methods are complicated, and their calculations should waste a lot of time. So, if all the outermost edges containing q on qo can pass through the face Fac formed by q and , it means that the object’s maximum field of view relative to the query point is blocked, and the spatial object is invisible to the query point q.
4. Visibility Detection of Convex Hull Model
According to the definitions and theorems in the last section, the visibility detection algorithm based on the convex hull model is introduced below, which will be used for the visual knearest neighbor query. The visual knearest neighbor query treats all the objects in front of the current query object as obstacles. It can be seen that the number of obstacles for the current query object is variable, and there may be one or more obstacles. The number of obstacles that can block the current query object is also variable. There may be one or more obstacles, and the query object representation model is a convex hull model.
For the visibility detection of a single obstacle, the positional relationship of the outermost edge of the “query pointobject visible body” and the surface of the “query pointobstacle visible body” is used directly to make judgments. The specific process of the visibility detection algorithm for obstacles represented by a single convex hull model is as follows:

The algorithm is described as follows. The query point q is added to the query object point set to form the original point set of the “query pointobject visible body” qObjHu. The outermost edges qToridge containing the query point q of the convex hull model are obtained (lines 2–4). The original point set O of the obstacle is used to construct the convex hull model ObsHull, and the surface triangle fac is obtained (lines 56). If there is a ridge line that does not pass through any surface, then the query object represented by the convex hull model is visible, and the result True is returned. Otherwise, it is invisible, and the result False is returned (lines 13–17).
For the visibility detection of multiple obstacles, we have to judge the relationship between the obstacles. The linesurface position detection method is used to make the judgment.
The “query pointobstacle visual bodies” between obstacles adopt the linesurface position detection method instead of the collision detection method between obstacles as is shown in Figure 9. There is no collision between obstacle Obs1 and obstacle Obs2, and both obstacles have an occlusion relationship for the query object, but the query object is invisible to the query point q. This is because the set of obstacles formed by Obs1 and Obs2 obscures the query object, the straight line from point q to the query object obj is occluded by the “combined obstacle” of Obs1 and Obs2.
The “query pointobstacle visual bodies” between obstacles adopt the linesurface position detection method instead of the collision detection method between “query pointobstacle visual bodies” based on obstacles as shown in Figure 10. The gray area in the figure is the visible area based on the point q. Obstacle Obs1 and Obs2 form the “query pointobstacle visual bodies” qObs1 and qObs2, respectively. If the collision detection method is used to detect whether qObs1 and qObs2 collide, the result obtained by this method is that the two objects always collide, because qObs1 and qObs2 have a common point q, which will inevitably lead to a collision. However, the “combined obstacle” formed by them blocks the visible area (gray area), and the linesurface position detection method will make the result more accurate and will not make wrong judgments because of the existence of q.
The construction method of “combined obstacle” in threedimensional space will be used to obtain the combined obstacles in the visual knearest neighbor query, and the positional relationship between multiple obstacles includes the following two types.(1)The obstacle obs does not collide with other “query pointobstacle visual bodies” based on other obstacles. Then, only the “query pointobject visual body” based on the query object needs to be detected by the positional relationship between the outermost edge of the visible body and the outermost surface of obstacle obs.(2)The obstacle obs collides with other “query pointobstacle visual bodies” based on other obstacles. We combine the point set of obstacle obs and the point sets of other obstacles which form the “query pointobstacle visual bodies” and collide with the obstacle obs to form a whole convex polyhedral obstacle set. Then, only the positional relationship between the outermost edge line containing q and the outermost outer surface of the convex polyhedron needs to be detected.
The positional relationship between obstacles may be that the obstacle in front occludes the obstacle completely in the back. Then, the results of “query pointobstacle visual body” based on the obstacles and linesurface position method detection are all “no ridge line passing through the obstacle surface,” but, at this time, the formation of combined obstacles has no effect on the result as shown in Figure 11.
The cross sections of obstacle Obs1 and obstacle Obs2 are relative to the query point q. There is no case where outermost edge lines containing q of qObs1 pass through the obstacle Obs2, but this situation does not affect the obstacle collection formed by obstacles and the visibility detection of the query object, because the occlusion of the query object by the obstacle Obs2 is equivalent to the “combined obstacle” of obstacle Obs1 and obstacle Obs2.

The algorithm is described as follows. Firstly, the point set of all obstacles is processed. Each original point set of the obstacle is added the query point q to form a “query pointobstacle visual body” based on the obstacle set O (line 2). A set ListExitIndex is initialized to store the obstacle ids of the established combined obstacles (line 3) and then loops through the set of all obstacles to check whether the current obstacles have established “combined obstacles” (lines 45). We establish “combined obstacle” for current obstacles if there is no one. It is divided into three steps. The first step is to obtain the outermost edges of the current obstacle (line 10). The second step is to obtain the outermost surface face of each of the “query pointsobstacle visual body” ListObs based on the obstacle set (line 11). The third step is to judge whether the lines of the current obstacle pass through the face of each obstacle. If there is a passing relationship, it means that the two obstacles can form a “combined obstacle”. We add the obstacle point set which collides with it to the combined obstacle set (lines 1213) until all obstacles are judged. Then, we add the current obstacle to the set of “combined obstacle” (line 16), and finally, a complete set of combined obstacles for the current obstacles is obtained (line 19).
5. Visual kNearest Neighbor Query of Convex Hull Model in 3D Spatial Space
The visual knearest neighbor algorithm of the convex hull model is processed as follows, which is divided into three steps. Firstly, the spatial objects are sorted by the distance to the query point from the nearest to the farthest. Secondly, collision detection is performed on the “query pointobstacle visible body” formed by the query object and the obstacle. Finally, the occlusion relationship of the query object and the obstacle is detected, and the complete or partial occlusion relationship is obtained. The spatial objects are judged in turn until the visual knearest neighbor query result that satisfies the condition is obtained.
5.1. The Shortest Distance of 3D Objects
The shortest distance from a point to a volume calculated in the threedimensional space is the minimum of all the distances from the point to the vertex of the body surface, the point to the edge of the body surface, and the point to the face of the body surface. The surface of the threedimensional convex hull is a closed bounding box composed of triangles, as shown in Figure 12.
Each triangle on the surface of the convex hull is represented by coordinates of three points. Through these coordinates, the plane equation of the triangle can be obtained, and the projection point from the point to the plane of the triangle can be obtained. If the projection point is inside the triangle (including the point inside the triangle, the point on the line segment, and the vertex of the triangle), the shortest distance from the point to the triangle is the length of the line segment formed by the point and the projection point. Otherwise, we calculate the distance from the point to each vertex of the triangle. After comparing the distances of the three vertices, the minimum value is the shortest distance from the point to the triangle, as shown in Figure 13.
The shortest distance calculation algorithm is as follows, which is used to calculate the shortest distance for visual knearest neighbor query.

This algorithm is used to calculate the shortest distance between the query point and the convex hull model of the current spatial object. The description of the algorithm is as follows. Firstly, the original convex hull point set O is used to construct the convex hull Hull, and the outermost surface fac is obtained (lines 23). Secondly, the minimum distance between the query point and the surface of the current convex hull is calculated. The specific method is as follows, and we calculate the distance from the query point to each triangular surface of the convex hull surface. If the query point is located in the visible direction of the current triangle surface, we calculate the shortest distance between the triangle and the query point (lines 4–6). Then, we compare the shortest distance between all the surfaces of the convex hull and the query point, and the minimum value is the shortest distance between the current convex hull and the query point (lines 78). Finally, the result of the shortest distance is returned (lines 1112).
5.2. Occlusion Judgment of Obstacle Set
Before the visual knearest neighbor query algorithm based on the convex hull model, occlusion judgment of the obstacles is considered firstly in 3D obstacle space. The obstacle set in the visual knearest neighbor query is a collection of obstacles, not a single obstacle.

The occlusion judgment algorithm is described as follows. Firstly, the query point q is added to each obstacle point set that collides with the “query pointobject body” based on the target object to form the “query pointobstacle body” based on the obstacle (lines 23), and the Concave and Ridge of each “query pointobject visual body” are obtained (line 34). These “query pointobstacle visual bodies” are based on Theorem 2: if there is an outermost edge line containing the query point of the “query pointobstacle visual body” based on the obstacle, Obs1 can pass through the outermost surface of the other obstacles, and Obs1 and the other obstacles can form a convex polyhedron. We make the judgment for all the obstacles, a convex polyhedron is formed (line 4), and check whether there is an outermost edge line containing the query point on the “query pointobstacle visible body” based on the current obstacle passing through the polyhedron outer surface (line 9), if exists, add it to the obstacle set (line 10–14), until the relationships between all other obstacles and the current obstacle have been judged, then the current obstacle point set is added to form a combined obstacle set (line 15). Finally, it is judged whether the set of obstacles occludes the query object completely, and returns the result (lines 18–24).
5.3. Visual kNearest Neighbor Query for 3D Objects
After the visibility detection algorithm and the shortest distance calculation algorithm based on the convex hull model, the visual knearest neighbor query is to proceed. The following is the specific process of the threedimensional visual knearest neighbor query algorithm based on the convex hull model.

The algorithm is described as follows. Firstly, according to the rule of “distant objects cannot affect the visibility of close objects” in the threedimensional space, the spatial objects are sorted according to the distance between the spatial objects and the query point in ascending order (line 2). Secondly, the query point is added to the surface point set of the target object, the query point and the target object form a “query pointobject visual body” (line 4), and the spatial objects in front of the current query object are all obstacles. The collision detection is performed between the “query pointobject visual body” and the objects in the obstacle set (lines 5–7). If the “query pointobject visual body based on the query object does not collide with any obstacle, it will be added to the result set and jump out of the current loop to continue the visibility detection of the next query object (lines 12–14). If the collision occurs, the obstacle that collided with the obstacle candidate set ObsSet is added to judge whether the obstacle in ObsSet occludes the query object completely (line 15), if it does not occlude the current query object completely, jump out of the current loop, and judge the visibility of the next query object, otherwise jump out of the current loop directly and determine the visibility of the next query object (line 15–17). Finally, the visual knearest neighbor query results which meet the conditions are obtained (line 21).
6. Experimental Results and Analysis
6.1. Experimental Environment Settings and Data
This experiment was under the Microsoft Windows 10 operating system based on a 64bit processor, the development environment was Visual Studio Enterprise 2015 and MatLab, the main program programming language was C#, and the hardware environment was Intel(R) Core(TM) i54200M CPU @2.50 GHz, quadcore, 8 GRAM.
The SpatialDataGenerator software is a spatial data generation tool that can be downloaded for free from the Internet. This paper used the software to generate random objects in threedimensional space. These objects were all axisaligned bounding boxes with regular shapes. However, the represented model of the spatial objects in the paper was a threedimensional convex hull. For comparative experiments, we needed to generate the coordinates of the point set of the convex hull in the axisaligned bounding box corresponding to the same position. The data set generated method adopted in the experiment was as follows. The extreme point coordinates of the axisaligned bounding box of each threedimensional spatial object were generated by SpatialDataGenerator software. We used the extreme point value of each bounding box as the interval range, and a random point set was generated within this range. These random point sets were the original point sets that constituted each convex hull. In order to reduce the amount of calculation, it was necessary to further prune the original point set that constituted each convex hull. After obtaining the coordinates of the point set that constituted each convex hull model, the convex hull generation algorithm was used to obtain the outermost surface of each convex hull. The outermost points obtained by the outermost surface were the surface point sets constituting the convex hull, and these surface point sets could represent the convex hull model. The data generation software was used to generate random threedimensional objects in the space of 400 × 400 × 400, and the dataprocessed method mentioned above was performed on each threedimensional object to obtain the corresponding internal convex hull model.
6.2. Analysis of Results
The visual knearest neighbor query algorithm proposed in this paper used the GJK collision detection algorithm to determine the occlusion relationships between objects and obstacles for the first time when the query was performed, and then, the linesurface relationship was used to determine the visibility of the objects. For comparative experiment, only the linesurface relationship judgment for visibility was used. In the experiment, it was not only for the linesurface relationship judgment but also the method of the combination of the GJK judgment and linesurface relationship judgment proposed in this paper. In order to describe the two methods better, the linesurface relationship detection method alone was named “linesurface” judgment, and the method of GJK collision detection combined with linesurface relationship detection proposed in this paper was named “GJK” judgment. In addition, R tree was constructed in the 3D obstacle space to compare with our proposed algorithm, which is called “3D RTree”. The experiment would be conducted from two aspects: the size of the data set and the value of the k. The experimental results were analyzed as follows.
The effect of data set size was analyzed on query performance, and the variable data set sizes were set to 50, 100, 150, …, and 500, respectively. The data sets were distributed uniformly, and the two algorithms were executed in the same experimental environment. Each experiment was run 5 times under each data set and k = 20, and the average value was used as the effective running time for comparison. The run times of the results were shown in Table 1.
These data were plotted into a line chart for analysis, as shown in Figure 14. It could be seen from the figure that as the data set increased, the query time of the algorithms increased responsively, but the query time of “GJK” judgment was always less than the query time of “linesurface” and “3D RTree”. This was because the larger amount of data, the number of spatial objects that the algorithms needed to judge whether they were visible was also increased, the “GJK” judgment algorithm proposed in this paper reduced the number of “linesurface” judgments, so the query performance was better. It also could be seen that as the data set increased, the growth rate of the “GJK” judgment would become flat. The “linesurface” judgment and the “3D RTree” had no such trend. This was because as the data set increased, the greater the data density, the greater the possibility that the objects were filtered out farther from the query point, because the objects that were farther away, the fewer objects that were visible completely. So, there were fewer data objects relatively for obstacle distance calculation. The other two methods needed to calculate all the data points, so they did not have such a trend. The “3D RTree” was constructed without overlapping parent nodes, and there was no multipath query problem, so the query speed was faster than the “linesurface” query. It could be concluded from the experiments that the “GJK” judgment algorithm proposed in this paper had a better performance.
We analyzed the influence of the k value on query performance and set the value of k to 5, 10, 15, …, 45, and 50, respectively, and the data set size remained unchanged at 500. The data sets were distributed uniformly, and the two algorithms were executed in the same experimental environment. A statistical method was used to support the experimental results. Each experiment was run 5 times under the value of each k, and the average value was used as the effective running time for comparison. The run times of the results were shown in Table 2.
The comparison of the experimental results of the algorithms was shown in Figure 15. As the value of k increased, all polylines showed an upward trend, but the “GJK” judgment polyline was always lower than the other two algorithms. By filtering objects, the number of objects involved in the calculation would be greatly reduced, which played an important role in the efficiency of the algorithm. The growth rate of the “3D RTree” was the largest. With the increase of query objects, the solution of multiway query could not improve the efficiency of the query effectively. The growth rate of the “GJK” judgment and “linesurface” was similar, but the “GJK” collision detection algorithm was more efficient, so its runtime is shorter than the “linesurface” judgment. The above situation showed that with the continuous increase of the k value, the “GJK” judgment algorithm had better query performance.
7. Conclusion
The spatial query in the obstacle space has received widespread attention as it is closer to the real world. Current studies on the visual query are focused on twodimensional space mostly and are less involved in threedimensional space. The objects with complex shapes in the threedimensional space become a new challenge to the visibility query. Aiming at this problem, a visibility detection method of the threedimensional object in obstacle space based on the convex hull model is proposed. And, by this method, the visual k nearest neighbor query is carried out. The study of this paper is concluded as follows.
Firstly, related definitions and theorems of the threedimensional convex hull model are given, and the method to detect the visibility of this model is proposed. The GJK collision detection algorithm is used to determine whether there is a collision between the convex hulls. If a collision occurs, the linesurface relationship is used to further judge whether it is visible. Secondly, the related algorithms of visibility detection based on the convex hull model are proposed. Thirdly, the shortest distance algorithm between the query point and the threedimensional convex hull and the obstacle occlusion judgment algorithm are given. Finally, the visual knearest neighbor algorithm based on the convex hull model is proposed based on the above algorithms.
The visual knearest neighbor query algorithm based on the convex hull model proposed in the paper is constructed in an experimental environment. The experimental comparison of two visual knearest neighbor query experiments by comparing the setting of the data set size and the size of the k value proves that the knearest neighbor query algorithm proposed in this paper has a better query performance.
The study of this paper has extensive application value in the process of industrialization. In the automotive industry, the application of autonomous driving technology can enable cars to avoid obstacles and find the best driving path during autonomous driving. In the medical field, it is used for mechanical surgery to achieve precise tumor resection. In the military field, precision strikes and radar detection of fighter jets can be achieved.
In this paper, the visibility detection method of threedimensional object is proposed in obstacle space based on the convex hull model to improve the accuracy of the visual query of objects in threedimensional space. However, in the study of visual query, multiple obstacles that collide with each other are combined into a “combined obstacle,” which is also represented by a convex hull. In real life, the combined obstacles formed by the collection of spatial obstacles may be concave. In this situation, the accuracy of the threedimensional space will be reduced when the visibility is detected. In view of this problem, indepth thinking and discussion can be carried out in future research. In addition, in the threedimensional space, the optimal path and the prediction of moving obstacles based on the convex hull model are also the next issues that we will focus on.
Data Availability
Spatial data generator is an open spatial database generation tool. Users can download from the Internet and generate data sets according to their needs.
Conflicts of Interest
The author declares that there are no conflicts of interest.
Acknowledgments
This work was supported by the National Natural Science Foundation under Grant no. 61972334, 2019 Hebei University Higher Education Science and Technology Research Youth Fund Project under Grant no. QN2019044, and Qinhuangdao science and Technology Bureau, Research and Development of Science and Technology in Qinhuangdao under Grant no. 201902A028.