Send Orders for Reprnts to reprnts@benthamscence.ae 262 The Open Cybernetcs & Systemcs Journal, 2015, 9, 262-267 The Shortest Path of Tourng Lnes gven n the Plane Open Access Ljuan Wang 1,2, Dandan He 2,*, Ansheng Deng 1 and Tao Nng 3 1 College of Informaton Scence and Technology, Dalan Martme Unversty, Dalan, Laonng, 116026, P.R. Chna; 2 Dept of Informaton and Scence, Dalan Insttute of Scence and Technology, Dalan, Laonng, 116052, P.R. Chna; 3 Software College, Dalan Jaotong Unversty, Dalan, Laonng, 116045, P.R. Chna Abstract: Gven two ponts p, q and a sequence of n lnes (n>1) n the plane, we want to fnd the shortest path of tourng all the gven lnes that starts at p and ends at q. In ths paper, we solve the problem by reducng t to the problem of fndng the shortest path that tours all the segments n a convex polygon from p to q. We frst ntroduce how to construct the convex polygon. Then, we propose the soluton to process the ntersectons of two adjacent segments by crossng over two segments. Fnally, based on rubber-band algorthm, a new algorthm s proposed whch can fnd the shortest path of tourng segments n a convex polygon, and the O(n 2 ) runnng tme can be obtaned for ths problem, whch mproves the prevous O(n 3 logn) tme. Our algorthm s smple and effcent. Keywords: Convex polygon, rubber-band algorthm, shortest path. 1. INTRODUCTION Path plannng s one of the central problem areas n computatonal geometry. The shortest tourng path problem s the most classcal example of path plannng, for example, fndng the shortest path of tourng a gven seres of obstacles between two ponts n the plane [1]. In ths paper, we focus on the soluton to fnd the shortest path of tourng gven lnes n the plane from p to q. The problem s as follows. Assume that there are two ponts p, q and n>1 lne l (for =1,2,, n) n a plane, we want to fnd the shortest path that tours all the gven lnes l from the start pont p to the end pont q, see Fg. (1). The problem gven above s abstracted from the shortest watchman route problem, and t s also the key to solve the shortest watchman route problem [2, 3]. The watchman route problem s derved from the well-known art gallery problem, and the goal s to fnd a shortest closed route n a smple polygon G such that one can see each pont n the polygon G from at least one pont of the route. Hakan Jonsson has presented an algorthm for fndng the shortest path that ntersects n lnes n the plane n O(n 5 ) tme [4]. No more optmal results have been reported recently. Many scholars have been studyng on the tourng segments problems and made some effectve results. For example, for the case n whch the gven segments don t ntersect, n 1984, D. T. Lee and F. P. Preparata proposed Funnel algorthm [5]. In 2007, Faje L and Renhard Kettle proposed rubber-band algorthm [6, 7] (denoted by R algorthm) wth K( ) O(n) tme, where K( )=(L 0 -L) /, L 0 s the ntal Fg. (1). The shortest path of tourng 5 lnes n the plane. shortest path length of tourng all segment set S, L s the actual shortest path, and n s the number of segments. In 2011, R algorthm s obtaned n O(n 2 ) tme by Wang and Huo by the experment. Furthermore, they mproved the algorthm and obtaned the O(n) tme by ntroducng dvde and conquer nto R algorthm [8]. For the case n whch the gven segments possbly ntersectng, the O(n 3 logn) tme algorthm for tourng a sequence of possbly ntersectng lne segments s known [9]. In our paper, the problem of fndng the shortest path for lnes can be converted to the problem of fndng the shortest path for segments n a convex polygon. We frst ntroduce how to construct the convex polygon. Then, on bass of R algorthm, a new algorthm s proposed whch processes the degradaton problem caused by the ntersecton by crossng over two segments when two adjacent segments ntersect. Fnally, we have mplemented t wth C++ program and obtaned the O(n 2 ) tme by experment. The result shows that the algorthm s effcent. 1874-110X/15 2015 Bentham Open
The Shortest Path of Tourng Lnes gven n the Plane The Open Cybernetcs & Systemcs Journal, 2015, Volume 9 263 2. THE METHOD OF CONSTRUCTING CONVEX POLYGON We use OPT(L) to denote the shortest path of tourng gven lne set L from p to q, snce OPT(L) s the shortest path, the parts between consecutve ponts of tour L are lne segments. Moreover, snce a non-convex route n the plane s strctly longer than the boundary of ts convex hull, and the convex hull of a route ntersects any target lne, we conclude that OPT(L) s convex [4]. It mples that OPT(L) vsts each target lne n one of three ways. If the angle of OPT(L) comng nto a lne l wth l (ncomng angle) s equal to the angle of OPT(L) gong away from a lne l wth l (outgong angle), OPT(L) makes a perfect reflecton on the lne l (see Fg. 2a). If OPT(L) passes the lne l twce, OPT(L) makes a crossng contact wth l (see Fg. 2b). The case n whch OPT(L) shares a porton of lnes wth l can be thought of a specal reflecton (see Fg. 2c). Here, we respectvely take the startng pont p and the endng pont q as the ntersecton of two lnes, thus the number of lnes n set L s n+4. We bound the regon n the plane where OPT(L) vsts the set L, and consder the convex hull C of all crossngs(see Fg. 3a). For sets L contanng no parallel target lnes, t can be shown that OPT(L) les n C, and the pont p and q les n C or on the boundary of C. However, f there are parallel lnes n set L, OPT(L) may be not contaned n the convex hull C (see Fg. 4). Snce C s convex, each of ts tangents parttons the plane nto two half-planes of whch the actve half-plane totally contans C. We make all tangents of C that are normal to target lnes, denoted by the set N, and consder the ntersecton G of the actve halfplanes of all tangents n set N (see Fg. 3b), we can conclude OPT(L) s contaned n G [4]. Thus, we can reduce ths problem to compute the shortest path between p and q whch vsts segments n the convex polygon G. 3. COMPUTE THE SHORTEST PATH OF SEG- MENTS IN A CONVEX POLYGON For the case n whch the segments n a convex polygon are dsjont, the soluton has been descrbed n detal n references [6-8]. For the case n whch the segments possbly ntersect, a new algorthm has been ntroduced as follows. (a) (b) (c) Fg. (2). Three types of contacts between OPT(L) and a lne l. (a) The convex hull C 3.1. The Method of Dealng wth the Intersected Segments When the segments ntersect, suppose that the segment s ntersects wth s +1 at the pont C, and q -1 s the path pont on s -1 and s the path pont on s +2. There are three cases between q 1 q and the segments s +2 and s +1, whch are as follows. (b) The polygon G (shaded and contanng C) Fg. (3). Constructng convex polygon. Case 1 q 1 ntersects wth s and s +1 In ths case, obvously, q 1q+ 2 s the local shortest path, denoted by d, d = q 1, and the order of d passng through s and s +1 s the tourng order, f d frst passes through s, the tourng order s s and s +1, otherwse, that s s +1 and s, see Fg. (5). Fg. (4). OPT(L) s not contaned n C.
264 The Open Cybernetcs & Systemcs Journal, 2015, Volume 9 Wang et al. (a) (a) Reflecton pont les on s. (b) Fg. (5). q 1q+ 2 ntersects wth s and s +1. (b) Reflecton pont les on s +1. Fg. (7). q 1q doesn t ntersect wth s + 2 and s +1. Case 3 q 1 doesn t ntersect wth s and s +1 (a) Reflecton pont les on s (b) Reflecton pont les on s +1 Fg. (6). q 1q ntersects wth s + 2 or s +1. Case 2 q 1 ntersects wth s or s +1 In ths case, to fnd the shortest path, computng the reflecton pont r on the lne segment s or s +1 s needed (see Fg. 6). The approach n the teraton process s as follows. If q 1 q only ntersects wth s +2 or s +1, the reflecton pont r les on the segment whch does not ntersect wth q 1, d = rq 1 + r, and the tourng order s the order of d passng through s and s +1, f d frst passes through s, the tourng order s s and s +1, otherwse, that s s +1 and s. In ths case, there are two cases whch are shown n Fgs. (7) and (8). (1) the case of computng one reflecton The two segments can be vsted by computng a reflecton pont (see Fg. 7). In ths case, obvously, d = rq 1 + r, here, when d passes through s or s +1 twce, we can deal wth t as above, f d frst passes through s, the tourng order s s and s +1, otherwse, that s s +1 and s. (2) the case of computng two reflectons When the two segments can t be toured by computng a reflecton pont, t needs to compute two reflectons. The approach s as follows. We make the reflecton ponts, denoted by q' -1 and q' +2, of q -1 and wth respect to s and s +1 respectvely. In ths case, there are also three stuatons when computng the local shortest path, see Fg. (8). (1) f q ' 1 q ' +2 ntersects wth s at the pont q and ntersects wth s +1 at the pont q +1, and the two path ponts q and q +1 are on the same sde of q -1 and, they are the two reflectons and also the path ponts. If q 1 q does not ntersect wth q +1, d = q 1 q + q q +1 + q +1 s the local shortest path, and the order of d passng through s and s +1 s the tourng order (see Fg. 8a). Otherwse, we need to change the tourng order of s and s +1 n order to get the local shortest path, then d = q 1 q +1 + q +1 q + q, see Fg. (8b).
The Shortest Path of Tourng Lnes gven n the Plane The Open Cybernetcs & Systemcs Journal, 2015, Volume 9 265 (a) (b) (c) (3) f q' 1q' + 2 doesn t pass the pont C and q' 1q' 2 on the dfferent sde of q 1C and Cq + 2, d = q 1C + Cq + 2, the path ponts q and q +1 also concde wth C, and the order of d passng through s and s +1 s the tourng order, see Fg. 8d). It can be proved as follows. In Fg. (8d), we select a pont q' on segment s and a pont q' +1 on s +1, snce q' 1 q' + q' q ' + 1 + q' + 1q' + 2 = q 1 q' + q' q ' + 1 + q' + 1q + 2, Cq ' 1 + Cq ' + 2 = Cq 1 + Cq + 2, obvously, + s q ' +2 q ' +1 + q ' +1 q ' + q ' q ' 1 > Cq ' + 2 + Cq ' 1, then q ' +1 + q ' +1 q ' + q ' q 1 > Cq+ 2 + Cq 1, d = Cq + Cq follows. + 2 1 3.2. Algorthm In ths paper, on bass of R algorthm, we apply a new algorthm to compute the shortest tourng path, wth crossng over two segments to process the ntersecton of them when these two segments ntersect. The algorthm s as follows. Assume that s nterests wth s +1, we can compute the path pont q on s and the path pont q +1 on s +1 accordng to the poston relaton between ponts and segments descred above. Next, we judge the poston relatonshp of s +1 and s +2, f s +1 s +2 =, we compute the path pont on s +2 and q +3 on s +3. Otherwse, we compute the path pont q +1 on s +1 and on s +2. The algorthm s composed of four functons whch are Man functon, UpdatePont functon, SkpOne functon and SkpTwo functon. Man functon calculates the shortest path by calculatng all the teraton process. UpdatePont functon calculates the shortest path n every teraton. SkpOne functon calculates the shortest path wth crossng over one segment. SkpTwo functon calculates the shortest path wth crossng over two segments. SkpTwo functon s the key to the algorthm. In reference [8], Man functon, UpdatePont functon, SkpOne functon have been descrbed n detal. Here, we manly gve the SkpTwo functon, t s descrbed below. SkpTwo ( q 1, s, s 1, q ) functon. + + 2 In ths functon, s and s +1 denote segments, q -1 and denote path ponts calculated on segments s -1 and s +2 respectvely. The functon s used to calculate the local optmal path of tourng s and s +1 from q -1 to, and the path ponts q and q +1 can be obtaned. (d) Fg. (8). q -1 and le on the same sde of s and s +1 (two reflecton ponts). (2) f q ' 1 q ' +2 passes the pont C, the reflecton ponts concde wth C and they are also the path ponts(q =q +1 =C), d = q 1 C + C, and the order of d passng through s and s +1 s the tourng order. We can make two auxlary ponts q' and q' +1 on s and s +1 and prove that easly, see Fg. (8c). Denote by r = q 1q+ 2, L the path calculated by SkpOne functon, and s ntersected wth s +1 at q. Case 1 q 1 ntersects wth s and s +1 If ( r s && r s +1 ), we consder that s ntersects wth r at c 1 and s +1 ntersects wth r at c 2 respectvely, let q = c 1 and q +1 = c 2, and f ( q 1 r 2 < q 1 r 1 ), call change ( s, s +1 ) and call change ( q, q +1 ). Case 2 q 1q+ 2 ntersects wth s or s +1
266 The Open Cybernetcs & Systemcs Journal, 2015, Volume 9 Wang et al. Fg. (9). The runnng result of 10 segments n a convex polygon. f ( r s r s+1 ) f ( r s ), call SkpOne ( q 1, s+1, q+2 ), and we consder that s ntersects wth L at c1 and s+1 ntersects wth L at c2 respectvely. Let q = c1, q+1 = c2 and rtmp = c2 q+2, else we compute the reflecton ponts, denoted by q'-1 and q'+2, of q-1 and q+2 wth respect to s and s+1 respectvely, let rtmp = q ' 1 q ' + 2, and denote s ntersectng wth rtmp at r1 and s +1 ntersectng wth rtmp at r2. f (q and q 1 le on the same sde of rtmp ), let q +1 = q = q. f ( rtmp s ), call chang ( s, s+1 ), else let q = c1 and q+1 = c2. and call change ( q, q+1 ). f ( r1q 1 else call SkpOne ( q 1, s, q + 2 ),we consder that s ntersects wth L at c1 and s +1 ntersects wth L at c2 respectvely. Let q = c1, q+1 = c2 and rtmp = c1q 1. f ( rtmp s+1 ) call change ( s, s+1 ), and call change ( q, q+1 ). Case 3 q 1q+2 doesn t ntersect wth s and s+1 Call SkpOne ( q 1, s, q+2 ). Denote by L ntersectng wth s at c1 and rtmp = c1q 1. f ( rtmp s+1 ), and the ntersecton s c2, then let q = c1, q+1 = c2, call change ( s, s+1 ) and call change ( q, q+1 ). else call SkpOne ( q 1, s+1, q+2 ). Denote by L ntersectng wth s+1 at c2, and rtmp = r2 q+2. f ( rtmp s ), and rtmp ntersects wth s at c1, q+1q+2 ), call change ( s, s+1 ) and call change ( q, q+1 ). 4. THE ANALYSIS OF RUNNING RESULT In ths paper, we have mplemented the algorthm wth C++ program. Here, we gve an example of tourng 10 segments n a convex polygon. In Fg. (9), the sold lnes are the segments whch the lnes ntersect wth the convex polygon, and the ntersectons are the endponts of segments. The path shown n dotted lnes s the shortest path of tourng the 10 lnes from S to T. We can see that the order of segments s from s1 to s10, whle the output order s dfferent from that of nput. Moreover, the three cases of path ponts and segments descrbed above have been contaned. q1, s3, s2, q6 s the case 1, q2, s6, s5, q7 s the case 2, and q7, s8, s10, T s the case 3. The runnng tme of the algorthm s complex and dffcult to analyze, so n ths paper, we adopt the method of analyss by runnng tme countng to analyze the algorthm s tme complexty. We have tested the algorthm applyng a large of segment sets (for example 500), and the segments number s 1000 n every segment set. Based on the results, we have got the fttng curve equaton of the algorthm, that s y= 1E-05x2 0.011x + 3.810, see Fg. (10). The results show that the algorthm s n O(n2) tme, and t s superor to
The Shortest Path of Tourng Lnes gven n the Plane The Open Cybernetcs & Systemcs Journal, 2015, Volume 9 267 CONFLICT OF INTEREST The authors confrm that ths artcle content has no conflct of nterest. ACKNOWLEDGEMENTS Ths work s supported by the Natonal Natural Scence Foundaton of Chna (No. 61173034, 61272171), the General Project of Laonng Provnce Educaton Department (No. L2014183) and the General Project of Dalan Insttute of Scence and Technology (No. KYZ1416). REFERENCES Fg. (10). The fttng curve equaton of the algorthm. the O(n 3 logn) tme of reference [9]. It can be seen that our algorthm s effcent. CONCLUSION In ths paper, we convert the problem of computng the shortest tourng path for lnes to the problem of computng the shortest tourng path for segments n a convex polygon, and we present an algorthm for computng the shortest tourng path of segments n a convex polygon, especally, we have mplemented t. The result shows that our algorthm s effcent. Ths research has made prelmnary results. If the segments haven t been gven the order, t has been proved to be a NP hard problem, f we study the shortest path of tourng rays, whch s open and les n between the problems concernng lnes and segments. Those problems need to be further studed. [1] M. de Berg, O. Cheong, M. van Kreveld, and M. Overmars, Computatonal Geometry: Algorths and Applcatons, (3 rd ed.), Sprnger-Verlag Publshers: Berln, 2009, pp. 10-11. [2] X. Tan, Fast computaton of shortest watchman routes n smple polygons, Informaton Processng Letters, vol. 77, no. 1, pp. 27-33, 2001. [3] A. Dumtrescu, J. S. B. Mtchell, and P.. yl sk, Watchman route for lne and segments, Algorthm Theory - SWAT 2012 Lecture Notes n Computer Scence, vol. 7357, pp. 36-47, 2012. [4] H. Jonsson, The travelng salesman problem for lnes n the plane, Informaton Processng Letters, vol. 82, pp. 137-142, 2002. [5] D. T. Lee, and F. P. Preparata, Eucldean shortest paths n the presence of rectlnear barrers, Networks, vol. 14, no. 3, pp. 393-410, 1984. [6] F. L, and R. Klette, Exact and approxmate algorthms for the calculaton of shortest paths, IMA Journal of Management Mathematcs, vol. 17, no. 1, pp. 134-138, 2006. [7] L. Fa-je, and K. Renhard, Shortest path algorthms for sequences of polygons, CAAI Transactons on Intellgent Systems, vol. 3, no. 1, pp. 23-30, 2008. [8] L. Wang, L. Huo, and D. He, An mproved algorthm for eucldean shortest paths of vstng lne segments n the plane, Journal of Convergence Informaton Technology, vol. 6, no. 6, pp. 119-125, 2011. [9] M. Dror, A. Efrat, A. Lubw and J.S.B. Mtchell, Tourng a sequence of polygons, In: Proceedngs 35 th Annual ACM Symposum Theory Computaton, Calforna, USA, 2003, pp. 473-482. Receved: September 16, 2014 Revsed: December 23, 2014 Accepted: December 31, 2014 Wang et al.; Lcensee Bentham Open. Ths s an open access artcle lcensed under the terms of the Creatve Commons Attrbuton Non-Commercal Lcense (http://creatvecommons.org/- lcenses/by-nc/3.0/) whch permts unrestrcted, non-commercal use, dstrbuton and reproducton n any medum, provded the work s properly cted.