<s>
In	O
computational	O
geometry	O
,	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
or	O
visibility	O
region	O
for	O
a	O
point	O
in	O
the	O
plane	O
among	O
obstacles	O
is	O
the	O
possibly	O
unbounded	O
polygonal	O
region	O
of	O
all	O
points	O
of	O
the	O
plane	O
visible	O
from	O
.	O
</s>
<s>
The	O
visibility	B-Algorithm
polygon	I-Algorithm
can	O
also	O
be	O
defined	O
for	O
visibility	O
from	O
a	O
segment	O
,	O
or	O
a	O
polygon	O
.	O
</s>
<s>
Visibility	B-Algorithm
polygons	I-Algorithm
are	O
useful	O
in	O
robotics	O
,	O
video	O
games	O
,	O
and	O
in	O
various	O
optimization	O
problems	O
such	O
as	O
the	O
facility	O
location	O
problem	O
and	O
the	O
art	O
gallery	O
problem	O
.	O
</s>
<s>
If	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
is	O
bounded	O
then	O
it	O
is	O
a	O
star-shaped	B-Algorithm
polygon	I-Algorithm
.	O
</s>
<s>
A	O
visibility	B-Algorithm
polygon	I-Algorithm
is	O
bounded	O
if	O
all	O
rays	O
shooting	O
from	O
the	O
point	O
eventually	O
terminate	O
in	O
some	O
obstacle	O
.	O
</s>
<s>
In	O
the	O
latter	O
case	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
may	O
be	O
found	O
in	O
linear	O
time	O
.	O
</s>
<s>
Formally	O
,	O
we	O
can	O
define	O
the	O
planar	O
visibility	B-Algorithm
polygon	I-Algorithm
problem	O
as	O
such	O
.	O
</s>
<s>
Then	O
,	O
the	O
point	O
visibility	B-Algorithm
polygon	I-Algorithm
is	O
the	O
set	O
of	O
points	O
in	O
,	O
such	O
that	O
for	O
every	O
point	O
in	O
,	O
the	O
segment	O
does	O
not	O
intersect	O
any	O
obstacle	O
in	O
.	O
</s>
<s>
Likewise	O
,	O
the	O
segment	O
visibility	B-Algorithm
polygon	I-Algorithm
or	O
edge	O
visibility	B-Algorithm
polygon	I-Algorithm
is	O
the	O
portion	O
visible	O
to	O
any	O
point	O
along	O
a	O
line	O
segment	O
.	O
</s>
<s>
Visibility	B-Algorithm
polygons	I-Algorithm
are	O
useful	O
in	O
robotics	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
robot	B-General_Concept
localization	I-General_Concept
,	O
a	O
robot	O
using	O
sensors	O
such	O
as	O
a	O
lidar	O
will	O
detect	O
obstacles	O
that	O
it	O
can	O
see	O
,	O
which	O
is	O
similar	O
to	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
.	O
</s>
<s>
Numerous	O
algorithms	O
have	O
been	O
proposed	O
for	O
computing	O
the	O
point	O
visibility	B-Algorithm
polygon	I-Algorithm
.	O
</s>
<s>
Naive	O
algorithms	O
are	O
easy	O
to	O
understand	O
and	O
implement	O
,	O
but	O
they	O
are	O
not	O
optimal	B-General_Concept
,	O
since	O
they	O
can	O
be	O
much	O
slower	O
than	O
other	O
algorithms	O
.	O
</s>
<s>
Then	O
,	O
the	O
pseudocode	B-Language
may	O
be	O
expressed	O
in	O
the	O
following	O
way	O
:	O
</s>
<s>
Furthermore	O
,	O
it	O
is	O
very	O
slow	O
,	O
since	O
one	O
may	O
have	O
to	O
shoot	O
many	O
rays	O
to	O
gain	O
a	O
roughly	O
similar	O
solution	O
,	O
and	O
the	O
output	O
visibility	B-Algorithm
polygon	I-Algorithm
may	O
have	O
many	O
more	O
vertices	O
in	O
it	O
than	O
necessary	O
.	O
</s>
<s>
This	O
is	O
because	O
any	O
bends	O
or	O
corners	O
along	O
the	O
boundary	O
of	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
must	O
be	O
due	O
to	O
some	O
corner	O
(	O
i.e.	O
</s>
<s>
This	O
is	O
because	O
the	O
algorithm	O
shoots	O
a	O
ray	B-Device
to	O
every	O
one	O
of	O
the	O
vertices	O
,	O
and	O
to	O
check	O
where	O
the	O
ray	B-Device
ends	O
,	O
it	O
has	O
to	O
check	O
for	O
intersection	O
with	O
every	O
one	O
of	O
the	O
obstacles	O
.	O
</s>
<s>
Given	O
a	O
simple	O
polygon	O
and	O
a	O
point	O
,	O
a	O
linear	O
time	O
algorithm	O
is	O
optimal	B-General_Concept
for	O
computing	O
the	O
region	O
in	O
that	O
is	O
visible	O
from	O
.	O
</s>
<s>
It	O
simply	O
walks	O
around	O
the	O
boundary	O
of	O
the	O
polygon	O
,	O
processing	O
the	O
vertices	O
in	O
the	O
order	O
in	O
which	O
they	O
appear	O
,	O
while	O
maintaining	O
a	O
stack	B-Application
of	O
vertices	O
where	O
is	O
the	O
top	O
of	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
stack	B-Application
constitutes	O
the	O
vertices	O
encountered	O
so	O
far	O
which	O
are	O
visible	O
to	O
.	O
</s>
<s>
If	O
,	O
later	O
during	O
the	O
execution	O
of	O
the	O
algorithm	O
,	O
some	O
new	O
vertices	O
are	O
encountered	O
that	O
obscure	O
part	O
of	O
,	O
then	O
the	O
obscured	O
vertices	O
in	O
will	O
be	O
popped	O
from	O
the	O
stack	B-Application
.	O
</s>
<s>
the	O
desired	O
visibility	B-Algorithm
polygon	I-Algorithm
.	O
</s>
<s>
For	O
a	O
point	O
in	O
a	O
polygon	O
with	O
holes	O
and	O
vertices	O
in	O
total	O
,	O
it	O
can	O
be	O
shown	O
that	O
in	O
the	O
worst	O
case	O
,	O
a	O
algorithm	O
is	O
optimal	B-General_Concept
.	O
</s>
<s>
However	O
,	O
it	O
relies	O
on	O
the	O
linear	O
time	O
polygon	B-Algorithm
triangulation	I-Algorithm
algorithm	O
by	O
Chazelle	O
,	O
which	O
is	O
extremely	O
complex	O
.	O
</s>
<s>
For	O
a	O
point	O
among	O
a	O
set	O
of	O
segments	O
that	O
do	O
not	O
intersect	O
except	O
at	O
their	O
endpoints	O
,	O
it	O
can	O
be	O
shown	O
that	O
in	O
the	O
worst	O
case	O
,	O
a	O
algorithm	O
is	O
optimal	B-General_Concept
.	O
</s>
<s>
This	O
is	O
because	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
algorithm	O
must	O
output	O
the	O
vertices	O
of	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
in	O
sorted	O
order	O
,	O
hence	O
the	O
problem	O
of	O
sorting	B-Algorithm
can	O
be	O
reduced	O
to	O
computing	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
.	O
</s>
<s>
Notice	O
that	O
any	O
algorithm	O
that	O
computes	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
for	O
a	O
point	O
among	O
segments	O
can	O
be	O
used	O
to	O
compute	O
a	O
visibility	B-Algorithm
polygon	I-Algorithm
for	O
all	O
other	O
kinds	O
of	O
polygonal	O
obstacles	O
,	O
since	O
any	O
polygon	O
can	O
be	O
decomposed	O
into	O
segments	O
.	O
</s>
<s>
A	O
divide-and-conquer	B-Algorithm
algorithm	I-Algorithm
to	O
compute	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
was	O
proposed	O
in	O
1987	O
.	O
</s>
<s>
rotational	O
plane	B-Algorithm
sweep	I-Algorithm
algorithm	O
to	O
compute	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
was	O
proposed	O
in	O
1985	O
and	O
1986	O
.	O
</s>
<s>
During	O
the	O
iteration	O
,	O
the	O
event	O
line	O
is	O
maintained	O
as	O
a	O
heap	B-Application
.	O
</s>
<s>
For	O
a	O
point	O
among	O
generally	O
intersecting	O
segments	O
,	O
the	O
visibility	B-Algorithm
polygon	I-Algorithm
problem	O
is	O
reducible	O
,	O
in	O
linear	O
time	O
,	O
to	O
the	O
lower	B-Algorithm
envelope	I-Algorithm
problem	O
.	O
</s>
<s>
By	O
the	O
Davenport	O
–	O
Schinzel	O
argument	O
,	O
the	O
lower	B-Algorithm
envelope	I-Algorithm
in	O
the	O
worst	O
case	O
has	O
number	O
of	O
vertices	O
,	O
where	O
is	O
the	O
inverse	O
Ackermann	O
function	O
.	O
</s>
<s>
A	O
worst	O
case	O
optimal	B-General_Concept
divide-and-conquer	B-Algorithm
algorithm	I-Algorithm
running	O
in	O
time	O
was	O
created	O
by	O
John	O
Hershberger	O
in	O
1989	O
.	O
</s>
