Continuous Visible Query for Three-Dimensional Objects in Spatial Databases

Present research of visible query focuses on points and segments in two-dimensional space, while disfigurements occur during processing of visible query in three-dimensional space. In this paper, Continuous Visible Range Query Based on Control Point (CVRQ-CP) is proposed to solve the visible query in a 3D spatial database. Firstly, the horizontal angle (HA) andVertical Projection Angle (VPA) for 3D objects in a spatial database were used in the visibility testing method. The HA and VPA in the processing of the continuous visible query created visibility changes, defining and confirming the control point. Finally, the algorithm of Continuous Visible Range Query Based on Control Point (CVRQ-CP) was proposed. Verified by experiments, the CVRQ-CP algorithm correctly deals with the visible query of 3D spatial objects. The CVRQ-CP algorithm has better superior accuracy over present visible queries in 3D spatial databases.


Introduction
Continuous query is a kind of common spatial query which is widely used in Location-Based Service (LBS).Some researchers study the continuous query in obstacle space which is named as visible query.Visible queries are widely used in the field of assistant decision, navigation, and security monitoring.Although researches into visible query as VkNN [1], CVkNN [2], and VRkNN [3] are numerous, they focus on two-dimensional (2D) space as points and segments.In recent years, three-dimensional space applications such as online games and virtual reality applications have become increasingly common.Present researches are unable to deal with the visibility of three-dimensional (3D) objects correctly because they cannot properly consider altitudinal dimension influence.Meanwhile, methods using double-project in horizontal plane and vertical plane to reduce dimensions are extremely inappropriate and the visible query for 3D objects based on hardware is too expensive to use on a large scale.So there is an urgent need for visible query algorithm in 3D space database.To solve this problem, a method of visibility testing for 3D objects based on horizontal angle (HA) and Vertical Projection Angle (VPA) is proposed and the processing of Continuous Visible Range Query based on this visibility testing method is presented.
To solve the visible query with 3D objects, this paper designs 3D objects models and presents the method of visibility testing based on these models.Because of the visibility changes between nonparallel 3D objects for a query interval in the processing of the Continuous Visible Range Query (CVRQ), the important definition control point is used to reduce computational complexity.We propose an algorithm of the CVRQ Based on Control Point, and its accuracy and validity are validated.
The remainder of the paper is organized as follows: Section 2 reviews related works and defines the problem to be solved.Section 3 proposes the method of visibility testing on 3D objects.Section 4 defines the control point in CVRQ and proposes the processing of CVRQ Based on Control Point (CVRQ-CP).Section 5 provides the accuracy and validity of visibility testing method and performance of CVRQ-CP algorithm by analyzing the experiment results.Section 6 provides the conclusions and future research plans.using grid computing.The main algorithms include JANUS [4], DYNTACS [5], ModSAF [6] and the improved algorithm is Bresenham algorithm [7].These algorithms test visibility based on grid computing and therefore request the scene as an integrated file.This defines the algorithms as loadbefore-calculate methods.The scale of the scene is greatly limited under this kind of method due to high requirements on the client's hardware and network.In recent years, the spatial database is widely used for virtual scenes but the grid computing pattern is not applied in this background.

Related Work and Definition
Alipour et al. [8] proposed an algorithm using quadratic preprocessing time and space to solve the visibility testing problem.Chen and Wang [9] researched weak visibility queries of line segments in simple polygons.Hershberger [10] constructed the visibility graph in a simple polygon in (||) time, whereas Ghosh and Mount [11] established its construction in ( log  + ||) time for a polygon with holes.Here, || is the number of edges in the resulting visibility graph.Nouri Baygi and Ghodsi [12] constructed the visibility graph in a polygonal domain in ( 2 log(√/)/√ +   ) time.However, these studies did not involve the visibility testing of 3D objects.Currently, there is no appropriate visibility testing algorithm for 3D objects in spatial database.Regarding research of visible query in databases, Zhang et al. [13] proposed an integrated framework that efficiently answers most types of spatial queries in obstacles databases.Nutanong et al. [1] defined a Visible k Nearest Neighbor (VkNN) search with minimum visible distance (MinViDist).The VkNN query incrementally computes the visible neighbors as the search space is enlarged.This brings response time of the query processing up to 35%.Gao et al. [3] introduced a Visible Reverse k Nearest Neighbor (VRkNN) search in a spatial database and proposed an efficient algorithm for VRNN query processing, assuming that  and  are indexed by -trees.No preprocessing was required, and half-plane property and visibility checks were utilized to prune the search space.Gao et al. [2] developed an efficient continuous visible nearest neighbor (CVNN) algorithm to tackle the CVNN problem by performing a single query for the entire query line segment.Lu et al. [14] used the Voronoi diagram to store and search potential visible objects, improving query speed while increasing the computational complexity.Gu et al. [15] proposed a Continuous k Nearest Neighbor (CkNN) query based on control point to improve CPU efficiency and I/O.Wang et al. [16] achieved Visible k Nearest Neighbor (VkNN) query on moving objects by using periodic queries and -tree indexes.
All the aforementioned research focuses on 2D spatial databases, and existing algorithms cannot properly deal with the visible query of 3D objects.If we test the visibility of 3D objects by dimension-reduction with double-projection as the present visibility testing method, results will be incorrect due to lack of a proper projection plane for 3D objects with different rotation angles.Thus, this paper addresses the problems of 3D objects visibility testing and query algorithms.

Definition
Definition 1 (three-dimensional spatial object).A three-dimensional spatial object is a cube (, , ) with  as the center of the cube, and  = (, , ), where , , and  are the coordinates of . = (  ,   ,   ), where  is the range of the cube.  ,   , and   are the ranges in each dimension. is the cube's rotation angle in horizontal plane (Figure 1).
In this model, the rotation angle in the vertical plane is zero by default, making the horizontal plane the unified projection plane.With different rotation angles in the horizontal plane, the projections of 3D objects do not have a unified vertical projection plane to reduce dimension through double-projection.Therefore, a new method for visibility testing of 3D objects is needed.Definition 3 (projection angle, PA).The 3D object is (, ,  1 ) and the query point is .Rectangle  is used to replace (, ,  1 ) during the visibility testing to simplify   calculation.At any point  in the segment , the highest corresponding point is  (Figure 3(a)).The rectangle  is the projection of (, ,  1 ) in the horizontal plane (Figure 3(b)).Then,  of ∠ is the projection angle (Figure 3(c)).
The projection angle in the vertical plane is used to describe the influences of height dimension on visibility of 3D objects.By defining these data models, why visible query in 2D could not be directly used in 3D through double-projection is explained.

Visible Range Query on
Three-Dimensional Objects

Visibility Testing on 3D
Objects.The visibility testing on 3D objects is divided into two parts.First, preliminary filter for projection is created in the horizontal plane.Second, visibility testing for the objects, which are completely obscured in the horizontal plane, is conducted.
During the visibility testing in the horizontal projection plane, all 3D objects are projected to the horizontal plane of the query point.The projection of 3D object is described as a segment to simplify calculations (Figure 4(a)).In the first step for visibility testing, 3D objects  1 ,  2 , and  3 are projected to the horizontal plane of query point .2D visibility testing of the projections filtered out visible objects.As shown in Figure 4(a), the projections of  1 and  3 are visible to , and therefore, the 3D objects  1 and  3 are naturally visible to .The projection of  2 is invisible to  in the horizontal plane because it is covered by the projection of  1 , resulting in 3D object  2 requiring further visibility testing in the vertical plane (the second step for testing).As illustrated in Figure 4(b), if the projection angle of  2 is larger than  1 ,  2 is visible to  even if its projection is completely obscured in the horizontal plane.This reflects the principle  that a farther object could not affect the visibility of a closer object.Therefore, to avoid the impact of inserted objects, visibility testing of 3D objects is done in order by MinDist.
The projection angle  of 3D objects acts as a variable in this second step of visibility testing.The projection angle is related to the distance  between the query point  and the projection of the 3D object in the level plane of query point (Figure 5(a)).The projection angle   is calculated as Formula (1), where  is the height of the 3D object and   is the distance between the query point  and the corresponding point .  is calculated as Formula (2), where (  ,   ) is the coordinates of point .The horizontal angle   between  and  is calculated as Formula (3).As shown in Figure 5(b), point  has the minimum distance between object  and query point .Therefore,   is the maximum projection angle between  and .Then, the coordinate system  −  based on   and   is built to describe the visibility of the 3D object using these three formulas.If the projection angle of  1 is bigger than  2 in the same horizontal angle, then  1 is not obscured by  2 .Otherwise,  1 is invisible: The function curve of the projection angle as calculated using Formulas (1) and ( 2) is shown in Figure 6(a).The axis is  and the -axis is , and the curve is of object .In the same way, the curves of  1 and  2 are illustrated in Figure 6(b).The visibility of 3D objects is calculated by comparing the projection angle in the same horizontal angle.The curves for objects  1 and  2 in Figure 4(a) are shown in Figure 6(b) and   2 <   1 .Therefore,  2 is obstructed by  1 all the time, and  2 is invisible to query point .

Visible Range Query in 3D
Objects.According to the visibility testing method based on the horizontal and projection angles, the algorithm of Visible Range Query (VRQ) in 3D object is proposed.In VRQ, the first step is to use a range query to determine involved objects.Then, the primary object set is sorted using MinDist.Finally, the visibility of the primary objects is calculated one by one.If an object is visible, its added to the result set, and the obstacle set is updated.Otherwise, it must be covered by other objects in the obstacle set.This process is looped until the entire primary set is completely processed.The obstacle set creates an obstacle curve in the  −  system (Figure 7(a)).The point in the curve is the maximum projection angle in the corresponding horizontal angle.For example,  2 is inserted into the obstacle set, and the obstacle curve is updated (Figure 7(b)).
According to these steps, the VCR algorithm is proposed as shown in Algorithm 1.
In line (1), the range query obtains the primary set of objects.Then, the set is sorted by MinDist.In line (3), the visibility testing of the objects is processed through the loop.In line (4), the primary filter is done in horizontal plane.If the projection of the object is not covered then the object is visible.Otherwise, further filtering based on the projection angle is conducted for more accurate visibility testing.Next, the projection angle curve in the  −  system is calculated, the resulting curve is compared to the obstacle curve, and the visibility of the object is calculated.After processing all objects, the result set is returned in line (11).

Continuous Visible Range Query. Continuous Visible
Range Query (CVRQ) is a range query and a visible query.The primary set of 3D objects is obtained by the range query, and the resulting set is calculated from the primary set through visibility testing.
Let us take a CVRQ with radius  as an example.In step one, the entire query interval is divided into a group of segments, and the range query for each segment determines the primary set of 3D objects.Then, the primary set is sorted and visible objects are obtained by visibility testing.
In the CVRQ, the visibility testing is a segment between the objects and query interval (Figure 8(a)).The visibility testing of segments is divided into two parts: one in a horizontal plane, and the other in a vertical plane.Only the projection angle of objects completely covered in the horizontal plane needs to be calculated in visibility testing.

Point Change and Control Point.
There is a distinctive visibility change during continuous visible query on 3D objects.The distances between the query point and 3D objects constantly change, along with the projection angles.This may cause the obstacle relationships between objects to also change.For example, when we walk along the street, a building may disappear behind another building.In this paper, the ℎ and  are defined as follows. 2 projection as  changes in the obstacle area OA( When  is just visible to the query point in the query interval, ℎ/ℎ =   /  , where  is the height dimension of the 3D object (Figure 9(a)).Since  is parallel to , ℎ/ℎ =   /  .Therefore,  ℎ >  ℎ due to ℎ > ℎ.The other points in  2 are invisible, so point  is the Point Change.Similarly, point  is PC in Figure 9(b).
Conclusively, the PC is related to the relationship between objects' rotation angles in horizontal plane.When   1 >   2 , the PC is the point which is the closest point in the projection of 3D object in the horizontal plane.Otherwise, the PC is the farthest point.
The trace of query is a query interval [, ] during Continuous Visible Range Query (CVRQ) on 3D objects.The projection angle between the object and the query interval is a continuous variable, and the visibility of object may change.For example,  1 is invisible to query point  due to  2 , but with travel from point  to point , the distance between  1 and the query interval is shortened while the distance between  2 and the query interval is lengthened.Therefore, the projection angle between  1 and the query interval decreases while the projection angle between  2 and the query interval increases.However, the visible relationship between  2 and the query interval may change if   1 is larger than   2 at a certain point in the query interval.That point is a control point (CP) to  2 .Since it divided the query interval into two subintervals for  2 by  1 , it is described as CP( 2 ,  1 ): Query interval [, ] and projections of objects  1 and  2 are shown in Figure 10.Since   1 >   2 , point  is the Point Change in  2 to  1 .For any point  in the query interval,  2 will be invisible because of  1 at some point.If a straight i c line which goes through point  crosses  1 at  and crosses [, ] at  so that   2 =   1 , then the relationship between   2 and   1 is the same as shown in Figure 11 and Formula (7).
Ultimately, the control point depends on the Point Change.As shown in Figure 12, point  is the Point Change (PC) of object  2 ,  1 represents object  1 , and  2 is the query interval. 3 is vertical to  2 .The coordinate of  is calculated  14.

Object
Result set Obstacle set using Formula (7). 4 is vertical to  3 and crosses  5 at point . 5 which is the line through points  and  crosses  2 at point .Point  is the control point as CP( 2 ,  1 ).The CP is unique as in Theorem 8 proof.
Theorem 8 (unique control point).According to the PC, the control point could be calculated and there is only one CP.
Proof.A vertical line crosses point  and meets  2 at point  (Figure 12).The resulting line is  3 .According to / =   /  , to get the only point  to satisfy the formula / =   /  , the vertical line  4 crosses point  and meets line  1 at point .Point  is unique because  4 is not parallel to  1 .Then, line  5 crosses the points  and  and meets  2 at point , and / =   /  .If there are two CPs in the query interval,  1 meets  4 at two points.This is impossible, and therefore, point  is the only control point.
If  1 is parallel to  2 , the objects have the same rotation angle in the horizontal plane, and the visible relationship between  1 and  2 will not change in the obstacle area.As shown in Figure 13, [, ] is the OA of object  2 by  1 .At any point  in the OA, a straight line crosses  1 at  and crosses  2 at .The rate of projection angles of these two points is invariable (Formula ( 8)), and the visible relationship will not change in the OA.In these calculations,  is the height dimension of the object: The obstacle area is divided into two subintervals with different visibility by the control point in the CVRQ.

Continuous Visible Range Query Based on Control Point (CVRQ-CP).
In Figure 14, the projections of 3D objects  1 ,  2 ,  3 , and  4 are sorted by MinDist.The height dimensions of the objects are 4, 5, 3, and 7, respectively.CP( 2 ,  1 ) is point .The results of visibility testing are shown in Table 2.
When  1 is inserted, the obstacle set is empty, so  1 is visible to the entire query interval, and  1 is put in both the result and the obstacle sets.Next,  2 is inserted by order.The VA and IA are obtained through visibility testing, and CP( 2 ,  1 ) is calculated.The VA and IA of object  2 are updated.Then, all objects are inserted one by one in order, and visibility testing is conducted.Finally, the result set is reconstructed and summarized.
The algorithm of Continuous Visible Range Query Based on Control Point is proposed as shown in Algorithm 2.
The range query based on the query interval [, ] in object  is done in line (1), and results are sorted by MinDist in line (2) to avoid the influence of inserted objects.In line (3), the visibility testing of obstacle objects is calculated in order.During testing, the control point is calculated if the insert object is not parallel to the obstacle object.If the CP is in the IA, then it needs to be recorded in the result set.In line (13), the result set is reconfigured to summarize the visible objects for each subinterval of the query interval.

Experimental Evaluations
This section compares performance of three algorithms of visible query: (1) Basic-Algorithm-one (Basic I); (2) Basic-Algorithm-two (Basic II), a double-projection algorithm that separately processes the projections of 3D objects in the horizontal and vertical planes and describes visibility by their intersection; (3) for (every element  in ) do (4) for (every element  in ) do (5) getVisibleArea; (6) if Boolean( parallel ) then (7) else (8) getControlPoint and update VisibleArea; (9) end if (10) end for (11) if  is visible then (12) add  to  and ; (13) end if (14)   Four datasets were created using the Spatial Object Data Generator and normally distributed in three-dimensional spaces.Table 3 lists all the parameters of datasets in the experiments.Dataset III contains 500 objects, as shown in Figure 15.The entire experiment is divided into two parts.The first part of the experiment is carried out in Datasets I, II, and III.The purpose of this part is to verify the correctness and performance of the 3D visibility testing method which is proposed in this paper.The second part of the experiment is carried out in Dataset IV to verify the influence of the query radius and the query interval length on the performance of CVRQ-CP.In the first part of the experiment, in order to prove the influence of the quantity and density of object on the accuracy and response time of the query, 500 queries were done for each of the three algorithms in Datasets I, II, and III.To verify the accuracy of the three algorithms, we upload the objects in result list of the visible query in 3DMax and verify the correctness by manual inspection.The radius of range query is 250 and the query length is 0 in these experiments.
Accuracy results are shown in Figure 16.Obviously, the CVRQ-CP algorithm is more accurate than the other two algorithms.In Basic I, the height dimension of the objects is not considered, and the result set of visible query underwent little change across the three different scales.Therefore, the average accuracy rate decreased as the number of 3D objects increased.In Basic II, projections in the vertical plane were unable to describe the relationship between two objects due to rotation in the horizontal plane, and therefore, the average accuracy rate decreased as the number of 3D objects increased.However, since Basic II considers the influence of height, it is more accurate than Basic I. Conversely, for the CVRQ-CP algorithm, the projection of a 3D object is considered a segment.Although the accuracy is not 100%, the rate of accuracy is much higher than in Basic I and Basic II.
Response time results are shown in Figure 17.Each object in query range must be read and calculated in all three algorithms.This results in reduced query speed.The number of objects in query range has obvious influence on the response time.The same algorithm with same parameters has distinctly different response time in three different datasets.The only reason is that the number of objects in query range is different.The response time of the visible query increases as the number of obstacle objects increases.Meanwhile,  compared in the same dataset, Basic I is fastest while the CVRQ-CP algorithm is slowest.In Basic I, visibility testing is only required once, in a horizontal plane.Meanwhile, the same calculation must be executed twice in Basic II, in both the horizontal and the vertical planes.On the other hand, CVRQ-CP algorithm includes projection angle calculation.Each visible object added to the obstacle set participates in the visibility testing of the subsequent object.Since the Continuous Visible Range Query is regarded as a range query for a segment, the radius and query length greatly influence the visible query.The number of relevant objects increases with increasing radius under the same query length.Furthermore, response time dramatically increases with an increasing number of relevant objects due to the iteration in visibility testing.Each object in obstacle set may create a subinterval needing calculation.
The second part of experiment is to prove the influence of the query length and radius on the response time and I/O performance.This part of the experiment is done in Dataset IV.Dataset IV contains 5000 objects, as shown in Figure 18.Table 4 lists all the parameters that are considered in the experiments, with numbers in bold representing default settings.In each experiment, only one parameter is changed in order to evaluate its impact on the performance, while all the other parameters are fixed at their defaults.We run 200 queries for each experiment, and the average performance is reported.
Response time results under different radius are shown in Figure 19.The number of relevant objects increases with increasing radius under the same query length.Furthermore, response time dramatically increases with an increasing number of relevant objects due to the iteration in visibility testing.Each object in obstacle set may create a subinterval needing calculation.
Response time results under different query length are shown in Figure 20.The number of relevant objects increases with increasing query length under the same radius.Furthermore, response time dramatically increases with an increasing number of relevant objects due to the iteration in visibility testing.Each object in obstacle set may create a subinterval needing calculation.
The average access number of node increased with the visible query radius and the radius of range.The result of I/O is shown in Figure 21.Conclusively, the visible query radius has more significant impact than the query interval length.As a result, the radius is very important in the visible query application.If the radius is too small, the VR scene will be too small to simulate a realistic view of the human to reduce the reality.On the other hand, a large radius may render response time too long to effect the application of visible query.

Conclusions
The visible query for three-dimensional objects plays an important role in large-scale virtual reality scenes, such as in online games and virtual cities.The algorithm Continuous Visible Range Query Based on Control Point (CVRQ-CP) proposed in this paper addresses the lack of a specific algorithm for visible query for three-dimensional objects.The visibility testing based on projection angles in the vertical plane describes the visibility of 3D objects, while the control point describes the distinctive visibility change caused by changing distances during continuous visible query for 3D objects.Experimentation showed CVRQ-CP accuracy as superior to present algorithms.

Definition 2 (
minimum euclidean distance (MinDist)).If  is the projection of the 3D object in the horizontal plane of query point , then MinDist is the minimum Euclidean distance between  and  (Figure 2(a)).MinDist between  and a query interval [, ] is the minimum Euclidean distance between  and any point in [, ] (Figure 2(b)).

Figure 2 :
Figure 2: MinDist between a 3D object and query point or query interval.

Figure 3 :
Figure 3: Projection in horizontal plane and projection angel in vertical plane.

Figure 5 :
Figure 5: Change of distance and projection angle.
Projection angle curves of objects  1 and  2

Figure 10 :
Figure 10: Confirm the control point by Point Change.

Figure 11 :
Figure 11: The projection angle of change point and Point Change.

Table 1 :
Visible area of inserted object.
2 ,  1 ), then when the query point moves from Point  to point  in the query interval, PC is the earliest, or latest, visible point in projection of  2 .
Definition 7 (control point (CP)).Control point is a point in obstacle area OA( 2 ,  1 ) that divides the OA( 2 ,  1 ) into two different parts.In one part,  2 is visible, and in the other part it is invisible because of  1 .

Table 2 :
Result of CVRQ-CP in Figure

Table 3 :
Datasets in the experiment.

Table 4 :
Parameter ranges and default values.