A Gradient Search Algorithm for the Maximal Visible Area Polygon Problem

This paper provides a gradient search algorithm for finding the maximal visible area polygon (VAP) viewed by an interior point in a simple polygon P . The algorithm is based on a natural partition of P into convex sets, such that each element of the partition is associated with a unique analytical form of the area function. We call this partition a back diagonal partition of P . Our maximal VAP algorithm converges in a finite number of steps, and is polynomial with a complexity of ( ) 2 2 O r n , for a simple polygon P with n vertices, and r reflex vertices. We use the maximal VAP algorithm as a basis for a greedy heuristic for the well known guardhouse problem with a computation complexity of ( ) 3 2 O r n .


Introduction
A visual polygon is a polygon in which any pair of points is mutually visible.A visible polygon from a point x in a simple polygon P with n vertices can be found with a computational complexity of ( ) O n by the algo- rithm of El Gindy and Avis [1].For each visible polygon, one may associate a real number representing its area.The area function over all points x P ∈ is not well behaved, being in general neither convex nor concave, including points that may be not differentiable and even discontinuous.Some properties of polygonal area functions may be found in [2].
The first problem we intend to solve is finding an interior point x that maximizes the area of the visual po-lygon.We denote this problem as the maximal visible area polygon (VAP) problem.This problem was studied by Cheong et al. [3], which suggested sampling a finite number of points inside the polygon found by its triangulation.
The algorithm we suggest for this problem is based on a gradient search which converges with a finite number of steps.In order to determine the size of each step taken in the gradient direction, we use a specialized partition of the polygon P into convex sets referred to as a back diagonal partition (BDP).This decomposition arises naturally through the introduction of "back diagonals" in such a manner that the area functional expression is invariant within the domain of each element of the partition.Gradient information along with jump points is combined in an algorithm which traces a path from some initial point in the polygon to a local maximal point.The developed algorithm has a computational complexity of ( ) O r n for a polygon P with n vertices and r reflex vertices.Such a path may be used to guide a mobile search robot in an enclosed 2D area.
A related problem of placing the minimum number of stationary guards to visually cover a room represented as a 2D polygon was first presented by Klee in 1973 [4] as the art gallery or guardhouse problem.The objective was to find the smallest set of points in a polygon, such that every point inside the polygon would be visible to at least one point in the set.Two points are visible to each other, if the line of sight connecting them lies inside the polygon.Several heuristics and complexity calculations are provided in [5] and [6] for different extensions of the guardhouse problems in which the observers are restricted to the vertices of the polygon, and the edges of the polygon, or not restricted at all.In this paper, we offer a greedy algorithm, which repeatedly uses the gradient search method for finding the maximal VAP, and for solving the guardhouse problem.This greedy heuristic terminates after a finite number of steps and is polynomial with time complexity of ( ) O r n .Although the original problem was described in terms of the positioning of guards, it had application to the positioning of surveillance cameras, motion sensors or other detection devices in enclosed environments.We assume that omni vision cameras (or several back to back cameras) are placed at the selected positions.This problem has recently become a popular security problem.For example, currently England has 5 million CCTV security cameras and is adding them at the rate of 100 per day in both inside and outside environments.
In Section 2, we define the maximal VAP problem and introduce useful notation.In Section 3, we introduce the concept of a hidden region, its area, and a back diagonal partition.These set the stage for the introduction of the maximal visible area polygon (VAP) gradient search algorithm described in Section 4. In Section 5, we use the gradient maximal VAP algorithm to form a basis for a greedy algorithm to solve an application in the form of the guardhouse problem, and illustrate it with a small example.Section 6 provides conclusions and future work.

Problem Definition and Notation
Before embarking on a formal definition of the problem we present a number of definitions and associated notation.A polygon P is a closed plane figure bounded by at least three straight connected line segments.A poly- gon P containing n line segments can be described using the vertices along its boundary Let i e denote a directed edge between adjacent vertices of P where ( ) A simple polygon is a polygon which does not contain any holes and whose edges do not intersect.Two points u and v in P are mutually visible if for all points w such that ( ) , lie within P .A vertex of P is said to be non-convex or reflexive if the angle between the two segments that share it as endpoints is greater than 180 when viewed from the interior of P .Reflex vertices can create hidden areas when viewed from some points inside the polygon.Figure 1(a) shows a simple polygon where vertex 6 v is a reflex vertex, inducing a hidden area with respect to an observation point.
We define ( ) , V p P as a visibility polygon, such that each point in V is visible by an observation point p .The area of V is denoted as When understood these will be written simply as ( ) V p and ( ) A p .Given a polygon P of size n , and a point p inside P , the visible polygon ( ) , V p P and its area ( ) ( ) , A V p P can be determined with a time complexity of ( ) O n [1].

The Maximal VAP Problem
Define a maximal visible area polygon (VAP) problem as finding a point p * for which ( ) ( )  The expression for the signed area of a polygon P , with vertex coordinates ( ) { } , , 1, , x y y ∑ Note, that ( ) A P represents the signed area of the polygon P , i.e. ( ) 0 A P > , if the vertices of P are in- dexed in counterclockwise order.The visible area function over all x P ∈ is not well behaved, being in general neither convex nor concave.Moreover, it may contain points that are not only non differentiable but discontinuous.For the example in Figure 2(c), the top flat square has a non differentiable boundary and discontinuous drops at its corners.

Local Maximal Visible Area Polygon (VAP) Gradient Search Algorithm
We propose a gradient search method which starts with a given observation point, and moves it in the direction of the maximal gradient until a local maximum is achieved.At each step of the algorithm, a different visible area is calculated (i.e. the polygon minus the hidden regions) as a function of the current point.The result of a step in the maximal area gradient direction will give the ( ) , x y coordinates of the new observation point.Since there are several local gradients (one for each hidden region), the final direction is determined by the resultant vector.For example, if polygon P has two hidden regions with respect to a given point p , then two gradients are calculated (one for each hidden area).If the gradients for hidden regions I and II are ( ) , x y and ( ) , x y , re- spectively, then the final gradient ( ) will be ( ) . Below we present several definitions, which will form the basis of a gradient search method to be described subsequently.

Basic Definitions and Notation
Given a simple polygon with vertices ordered in counterclockwise order, for any three consecutive vertices ( ) x y = define a turn: T as: . We say that 1 2 3 v v v is a left turn if T is positive, a right turn if T is negative, and not a turn otherwise.
Proposition 1 Let a chain Q be a sequence of connected, nonintersecting line segments.Given two points y and z , such that the line segment yz does not intersect any line segment of Q , then y and z are said to be mutually visible with respect to chain Q .
, , , m Q q q q = be a simple chain such that 1 q and m q are visible with respect to Q .If a point y is exterior to the region enclosed by ( ) , Q q and collinear with 1 q and m q , then the region Hidden Area enclosed by ( ) 1 , Q q is not visible from y .The proof appears in [1]., , , ,

Hidden Area Point of Observation
The point y is collinear with 1 q and 5 q , and therefore, cannot see the region enclosed by ( ) q q is said to be a window of y with respect to the region enclosed by ( ) 1 , Q q .This region is said to be a hidden re- gion with respect to y .Note, that if m q is visible from y then so is 1 q .We denote the window, ( ) of y , as a left hand window (LHW) if 1 m m yq q − is a left turn, and as a right hand window (RHW) if 1 m m yq q − is a right turn.Looking back at Figure 1, we can see that 1 m m yq q − is a left turn.Let p be a viewpoint inside P and s a reflex vertex on the boundary of P .We classify reflex vertices as active or inactive according to the possibility of each creating an area occluded from p .In order to determine whether a reflex vertex s is active or inactive with respect to a given viewpoint p , we extend the adjacent edges of s into the interior of P until they hit the boundary to obtain back diagonals 1 χ and 2 χ .If p and s are mutually visible and p lies outside the angle 1 2 , , s χ χ , then s is said to be an active reflex point, otherwise s is inactive.Given a viewpoint p and an active reflex point s , define a ray ps Λ from p in the direction of s and passing through s .Let , , , q I p p p = be the set of intersection points of the ray with the boundary of P , ordered according to the distance from p .Denote the intersection point closest to p as a reflection point p′ .Figure 3(a) shows the reflection point p′ (the first intersection point) with respect to a viewpoint p and an active reflex vertex s .

Back Diagonal Partition (BDP)
Consider a pair of vertices u and v on the boundary of P , such that u is a reflex vertex and v is visible from u .Define a diagonal uv as a line segment directed from vertex u to vertex v .A back diagonal uv′ with respect to uv is a line segment joining the vertex u and the point v′ , where v′ is the nearest point on the edge of P visible in the reverse direction of uv .The point v′ is said to be a reflection point on the boundary of P visible from v along a ray directed from v through u .Figure 4 shows a back diagonal uv′ created by a reflex vertex u and a vertex v visible from u .Figure 5 shows an example of all back diagonals (dotted lines) induced by the reflex vertices.The introduction of all back diagonals induces a back diagonal partition (BDP) of P .Such a partition is a planar graph de- fining a set of internal regions.Note that five back diagonals are induced by vertex 10 v -one for each of the vertices in P visible from 10 v .Proposition 3 A BDP of P partitions P into a collection of regions, each a convex sub polygon of P .Proposition 4 A back diagonal is an edge in a BDP such that viewpoints in the neighborhood on either side of it have different visible and area polygonal functional expressions.Thus, each region in a BDP has a unique visible and area polygonal functional expression.
The above propositions will be useful in construction an algorithm for the maximal VAP problem.

Hidden Regions
Note that the gray areas in Figure 3 are hidden regions with respect to the viewpoints p .We define back edges for two cases.Case 1: If p′ is an interior point of an edge e of P , then p′ is said to be a point of p on e through the active reflex vertex s , and e is called a back edge of p through s .The 7 8 v v in Figure 3 is the back edge of the viewpoint p through the reflex vertex s .Case 2: If p′ coincides with a vertex i v of P , then the back edge is taken as ( ) In this case, i v and s induce a back diagonal on which p lies.For ease of exposition, all of the following will be in terms of case 1. Note, that case 1 corresponds to a point p that does not lie on a back diagonal with respect to s .A left hand hidden region ( ) H L with respect to p , a left hand active reflex vertex s , a reflection point p′ and its back edge , , , , , , , , , , , , , , and s are the original vertices of P in CCW order.A right hand hidden region ( ) H R is similarly defined for a right hand reflex vertex as , , , , , , , , , We can now define a visible polygon in terms of the definitions given above.Given a polygon P and an observation point p , define the visible polygon ( ) V p as polygon comprised of subsequences of the origi- nal vertices of P and all windows with respect to p .The visible polygon ( ) V p contains all visible vertices and the reflection points of all active reflex vertices with respect to p .From proposition 2 it should be clear that the regions enclosed by ( ) ( ) H R are not visible from p .

Calculation Formulas Using Hidden Areas
Define a rectangular coordinate system in 2  E such that each point i in 2 E is represented by a set of ordered real valued coordinates ( ) x y .Given the coordinates of an observation point ( ) , the end points of back edge ( ) , v v , and an active reflex point s , the reflection point p′ can be calculated as a function of p and has the general form: , Here, i α ( ) are constants comprised of the coordinates of the original boundary vertices of P .This is a direct result of applying Equation (2) to the boundary vertices ( ) , , , , , , , , , , , , , , ′ ′ of the left and right hidden regions, respectively.Given a point p in P , asso- ciate with it a set of active reflex vertices.Let  The collection of left and right hand hidden regions associated with p are denoted as; , respectively.Since intersections of hidden regions are empty (except for possible vertex points), the area of the visible polygon may be represented as follows: This area function will be derived in terms of the rectangular ( ) x y coordinates of point p , in order to determine the directional move of p , such as to increase the visible area.For example, Figure 6 shows a poly- , , , , , , , , , , , , , H L p s , and a visible polygon , , , , , , ,  ,  , , AL A P A H L p The only relevant vertices are the reflex vertex s (which created the hidden region) and 1 v which is the visible vertex of the edge ( ) , the back edge of p through s .Note that p′ is the intersection point between the line collinear with ( ) , p s and e .Repeating the process for a right hand side region, where 2 v is the visible vertex of the back edge e we obtain: The individual coordinates of p′ can be convex or concave, increasing or decreasing or constant in p x and p y depending on the orientation of the ray ps and the back edge ( )

Gradient Search Algorithm for Maximal VAP
Following are the steps of a gradient search algorithm for finding a local max to the maximal visible polygon problem. the current point p , the algorithm finds the maximal gradient direction and moves p until one of a number of events occurs.These events are determined when the functional form of the area function undergoes a change if the move is continued.This occurs, for example, when the point hits a back diagonal or an original edge of P .Also, when the refection point moves to an end point of its back edge, or when a new reflex point becomes active.At any of these events a new area function is introduced and the gradient is recalculated to determine a new movement direction.

Determination of the Maximal Gradient Direction
Since p x ′ and p y ′ depend on the view point p , we must rephrase the area's formulation using its coordinates.To do this two lines are constructed: : L ay bx c = + (connecting p and s ) and : L ay bx c = + (collinear with the back edge ( ) , v v ) (see Figure 5).The intersection of L and L is the point ( ) x y ′ ′ .The right side of (9) contains functions of p′ .

( ) , , p p ac ac cb cb x y ab ab ab ab
The total gradient p ∇ is the sum of the partials for all active reflex vertices with respect to p . (

Max VAP Algorithm (the Gradient Search Algorithm)
Although this algorithm is based on movements between sub regions of a BDP, there is no need to actually construct it.It is only necessary to construct the back diagonals (line equations).This is because the algorithm searches for a critical event when the observer crosses a back diagonal.At his point, based on proposition 4, a recalculation of the area and new gradient are necessary.
The Steps of the Procedure Given a simple polygon, and a point 0 p in P .Set 0 p p = .
Step 1 Compute the area of P as ( ) Step 2 Determine the visible polygon ( ) V p from p and its area ( ) ( ) ( ) . Identify all "active" reflex vertices 1 2 , , , w s s s and the corresponding set of windows: where k s is the th k active reflex vertex, and k p′ its reflection point which lies on the interior or endpoint its asso- Step 3 Find the total gradient p ∇ that maximizes the increase in ( )

( )
A V p , using (12) and Proposition 5.If no such gradient exists, stop and go to Step 6.
Step 4 If p lies on an original edge of P , calculate a new gradient direction so as to slide along the edge in a direction such that the angle between the original gradient direction and the edge is minimal.
Step 5 Move p in the gradient direction until one of the following critical events occurs: a) p hits a vertex or edge of P .b) One of the reflection points k p slides to the endpoint of its back edge k i e (i.e. one of the vertices of P ).c) If one of the windows k W becomes collinear with one of the edges that forms a reflex vertex, i.e.; ( )

( )
A V p * , the total visible area from p * .
Note that the events in Step 5 correspond to the intersection of the gradient direction vector and all back diagonals.

Proposition 5
The sequence

Proposition 6
The Gradient Search Algorithm converges in a finite number of steps.This is true since the sequence in Proposition 1 is bounded from above by the area of P .
Proposition 7 The gradient search algorithm has a time complexity ( ) O r n .
Proof.In Step 2, the initial polygon can be calculated in time ( ) O n .This also identifies all active reflex ver- tices (bounded by r ).Finding p ∇ will requires at r most calculations.In Step 3, the movement in the direction of p ∇ is performed until hitting a boundary edge or back diagonal.This requires r n ⋅ calculations to find all intersections between the gradient directional line and all back diagonal lines.Steps 2 and 3 are repeated at most r n ⋅ times in moving from back diagonal to back diagonal (resulting in at most r n ⋅ points between 0 p and p * as back diagonals are not revisited.Thus, the total time complexity of the gradient search algo- rithm is O n r rn rn O r n + + ⋅ ≈ .

Illustrative Example for the Maximal VAP Problem
The example in Figure 7 provides a demonstration of the algorithm for the case of a simple polygon with three reflex vertices, one of them, 4 v remaining inactive throughout.The sequence of points and visible areas are

Application-Solving the Guardhouse Problem
The guardhouse problem, proven to be NP-Hard in [4], is defined as the problem of the finding the minimal number of observation points F in a given a simple polygon P such that, the union of the visible area of all points in F equals P .

{ } ( )
Min , , subject to : , ∪ A greedy algorithm is described for solving the guardhouse problem which uses the maximal VAP algorithm.The idea is to start with a simple polygon, and remove a maximal VAP.This operation can result in disconnected components, each in itself a simple polygon.The process is repeated for any remaining components.Each removal results in an additional observation point, so that the number of removals equals the number of points needed to view the entire original polygon.

The Greedy Heuristic
Given a simple polygon P , let Π be a collection of polygons.
1) Initially set , remove P from Π and set it to the current polygon P .The greedy heuristic described above terminates after a finite number of steps.The complexity of the greedy heuristic for solving the guardhouse problem is ( ) O r n .There are at most r visits to Step 2 each requiring a call to the max VAP algorithm.Thus, the time complexity of the greedy heuristic is ( ) ( )

Illustrative Example
Figure 8(a) shows a sample polygon containing 16 vertices.We start with point shown in (b) and improve it until reaching a local maximum.The visible area is then removed from the initial polygon, and two new sub polygons appear in (c).In (d) and (e), this process is repeated with the two parts left, resulting in the final solution (f) in which the entire polygon is covered by 4 observation points.

Conclusions and Future Work
This work defined the maximal VAP problem, and offered a gradient algorithm for its solution which had a time complexity of ( ) O r n .In most practical environments, r is much smaller than n , such that the complexity can be in fact much closer to ( ) O n .The algorithm was used as a basis for a greedy heuristic procedure for solving the guardhouse problem with a time complexity of ( ) O r n .This heuristic procedure can be used for various applications in the field of homeland security such as placing indoor surveillance cameras or motion sensors.Several small examples are presented to illustrate the procedure.It will be interesting to compare the results of our suggested procedure to other well-known heuristics for the guardhouse problem offered by other researchers.Such a comparison must include not only the quality of the solution, but also the running times.This is left for future work.

Figure 1 .
Figure 1.Simple polygons with hidden areas.(a) A simple polygon containing a reflex vertex; (b) A region created by a chain of vertices which are not visible from an observation point.

Figure 1 (
Figure 1(b) shows an example of a point y exterior to a chain

Figure 3 .
Figure 3. (a) A reflection point p′ , with respect to a given viewpoint p and an active reflex vertex s ; (b) Left and right hand hidden regions with respect to a given viewpoint p .

Figure 4 .
Figure 4.A back diagonal uv′ created by a reflex vertex u and a vertex v visible from u .

Figure 5 .
Figure 5.A back diagonal partitioning for a polygon with three reflex vertices.
by the polygon defined by the circular vertex list:

Figure 3
a given observation point p .
the number of left and right ref- lex vertices with respect to p .Each active reflex vertex i has an associated hidden region.Let i H R p i represent a left/ right hidden regions of p associated with an active reflex vertex i , respectively.

Figure 6 .
Figure 6.A simple polygon with a left hand hidden region.

(
all active left and right reflex vertices with respect to p , respectively.

2 ). 3 )
Start with a random point p in P .Call the Max VAP gradient search algorithm to find the point p * , Let P be the set of simple polygons obtained by subtracting the visibility polygon ( ) , V p P * from P .(i.e. the parts of the polygon P which are not visible from p * ).Add P to the collection of polygons Π .4) If φ Π = stop, otherwise; 5) Select a polygon P in Π and remove it, and return to Step 2.

Figure 7 .
Figure 7. Steps of the max VAP algorithm staring with an initial view point 0 p .

Figure 8 .
Figure 8. Example solution to the guardhouse problem using the greedy VAP heuristic algorithm. , , ,