Computing the Visibility Graph of Points Within a Polygon Boaz Ben-Moshe Computer Science Ben-Gurion University Beer-Sheva 84105, Israel benmoshe@cs.bgu.ac.il Olaf Hall-Holt Applied Math. & Statistics Stony Brook University Stony Brook, NY 11794-3600 olaf@ams.sunysb.edu Matthew J. Katz Computer Science Ben-Gurion University Beer-Sheva 84105, Israel matya@cs.bgu.ac.il Joseph S. B. Mitchell Applied Math. & Statistics Stony Brook University Stony Brook, NY 11794-3600 jsbm@ams.sunysb.edu ABSTRACT We study the problem of computing the visibility graph de- fined by a set P of n points inside a polygon Q: two points p, q ∈P are joined by an edge if the segment pq Q. Ef- ficient output-sensitive algorithms are known for the case in which P is the set of all vertices of Q. We examine the general case in which P is an arbitrary set of points, interior or on the boundary of Q and study a variety of algorithmic questions. We give an output-sensitive algorithm, which is nearly optimal, when Q is a simple polygon. We introduce a notion of “fat” or “robust” visibility, and give a nearly opti- mal algorithm for computing visibility graphs according to it, in polygons Q that may have holes. Other results include an algorithm to detect if there are any visible pairs among P , and algorithms for output-sensitive computation of vis- ibility graphs with distance restrictions, invisibility graphs, and rectangle visibility graphs. Categories and Subject Descriptors: F.2.2 [Analy- sis of Algorithms and Problem Complexity]: Nonnumerical Algorithms and Problems—geometrical problems and com- putations General Terms: Algorithms, Theory Keywords: Visibility graphs, polygons, illumination, guard- ing, fatness, output-sensitive algorithms 1. INTRODUCTION The visibility graph is a fundamental geometric structure useful in many applications, including illumination and ren- Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. SCG’04, June 8–11, 2004, Brooklyn, New York, USA. Copyright 2004 ACM 1-58113-885-7/04/0006 ...$5.00. dering, motion planning, pattern recognition, and sensor networks. Let Q be a polygon with n vertices. Let P = {s1,...,sm} be a set of m points (sites) in Q; the points in P may lie both on the boundary of Q and in the interior of Q. The visibility graph of P in Q, denoted VGQ(P ), is the graph whose nodes are the points P and whose edges connect pairs of nodes that see one another within Q (i.e., the segment joining the points lies within Q). See Figure 1 for an example. In this paper, we present efficient algorithms to compute VGQ(P ). There has been considerable study of visibility graphs and algorithms to compute them (see, e.g., [24]). Optimal algo- rithms are known for computing the visibility graph of all vertices of Q (i.e., the case that P = V is the vertex set of Q): one can compute VGQ(V ) in time O(n + k) if Q is simple, or time O(n log n + k) if Q has holes, where k is the size of the output. The algorithms for computing VGQ(V ) exploit the structure of the entire visibility graph VGQ(V ) in achieving their efficiency, charging off work to the edges. For our more general problem of computing VGQ(P ) for any set of sites P within Q, there are two immediate solu- tions based on existing techniques: (1) We can build the supergraph, VGQ(V ∪P ), in time O((n + m) log(n + m)+ k ), where k is the size of the output, and then report only those edges of in- terest to us (those of VGQ(P )); however, k could be enormously greater than the size of the desired out- put – e.g., k may be Ω(n 2 ), with n >> m, while the size of VGQ(P ) may be very small (e.g., O(m), or O(1)). Computing the relative convex hull, C, of P with respect to Q, and then computing the free bitan- gents [22] within C reduces the number of superfluous edges computed, but there may still be a substantial discrepancy between the Ω(m 2 ) edges that may be re- ported and the output size (possibly O(1)). (2) We can preprocess Q for ray shooting queries and then conduct a query for every pair of points of P , thereby determining VGQ(P ). This method takes time O(m 2 q(n)), where q(n) is the time for performing a ray-shooting query: q(n)= O(log n) if Q is simple,