VisiLibity v1 Source Code 1.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
VisiLibity::Visibility_Polygon Class Reference

visibility polygon of a Point in an Environment or Polygon More...

#include <visilibity.hpp>

Inheritance diagram for VisiLibity::Visibility_Polygon:
VisiLibity::Polygon

Classes

class  Incident_Edge_Compare
 
struct  Polar_Edge
 
class  Polar_Point_With_Edge_Info
 

Public Member Functions

 Visibility_Polygon ()
 default to empty
 
 Visibility_Polygon (const Point &observer, const Environment &environment_temp, double epsilon=0.0)
 visibility set of a Point in an Environment More...
 
 Visibility_Polygon (const Point &observer, const Polygon &polygon_temp, double epsilon=0.0)
 visibility set of a Point in a Polygon More...
 
Point observer () const
 location of observer which induced the visibility polygon
 
- Public Member Functions inherited from VisiLibity::Polygon
 Polygon ()
 default to empty
 
 Polygon (const std::string &filename)
 construct from *.polygon file More...
 
 Polygon (const std::vector< Point > &vertices_temp)
 construct from vector of vertices More...
 
 Polygon (const Point &point0, const Point &point1, const Point &point2)
 construct triangle from 3 Points More...
 
const Pointoperator[] (unsigned i) const
 access with automatic wrap-around in forward direction More...
 
unsigned n () const
 vertex count More...
 
unsigned r () const
 reflex vertex count (nonconvex vertices) More...
 
bool is_simple (double epsilon=0.0) const
 true iff Polygon is (epsilon) simple More...
 
bool is_in_standard_form () const
 true iff lexicographically smallest vertex is first in the list of vertices representing the Polygon More...
 
double boundary_length () const
 perimeter length
 
double area () const
 
Point centroid () const
 Polygon's centroid (center of mass) More...
 
double diameter () const
 Euclidean diameter. More...
 
Bounding_Box bbox () const
 box which fits snugly around the Polygon More...
 
std::vector< Pointrandom_points (const unsigned &count, double epsilon=0.0) const
 
void write_to_file (const std::string &filename, int fios_precision_temp=FIOS_PRECISION)
 write list of vertices to *.polygon file More...
 
Pointoperator[] (unsigned i)
 access with automatic wrap-around in forward direction More...
 
void set_vertices (const std::vector< Point > &vertices_temp)
 set vertices using STL vector of Points
 
void push_back (const Point &vertex_temp)
 push a Point onto the back of the vertex list
 
void clear ()
 erase all vertices
 
void enforce_standard_form ()
 enforces that the lexicographically smallest vertex is first in the list of vertices representing the Polygon More...
 
void eliminate_redundant_vertices (double epsilon=0.0)
 eliminates vertices which are (epsilon) - colinear with their respective neighbors More...
 
void reverse ()
 reverse (cyclic) order of vertices More...
 

Private Member Functions

bool is_spike (const Point &observer, const Point &point1, const Point &point2, const Point &point3, double epsilon=0.0) const
 
void chop_spikes_at_back (const Point &observer, double epsilon)
 
void chop_spikes_at_wrap_around (const Point &observer, double epsilon)
 
void chop_spikes (const Point &observer, double epsilon)
 
void print_cv_and_ae (const Polar_Point_With_Edge_Info &current_vertex, const std::list< Polar_Edge >::iterator &active_edge)
 

Private Attributes

Point observer_
 

Additional Inherited Members

- Protected Attributes inherited from VisiLibity::Polygon
std::vector< Pointvertices_
 

Detailed Description

visibility polygon of a Point in an Environment or Polygon

A Visibility_Polygon represents the closure of the set of all points in an environment which are {\it clearly visible} from a point (the observer). Two Points p1 and p2 are (mutually) {\it clearly visible} in an environment iff the relative interior of the line segment connecting p1 and p2 does not intersect the boundary of the environment.

Remarks
average case time complexity O(n log(n)), where n is the number of vertices in the Evironment (resp. Polygon). Note the Standard Library's sort() function performs O(n log(n)) comparisons (both average and worst-case) and the sort() member function of an STL list performs "approximately O(n log(n)) comparisons". For robustness, any Point (observer) should be epsilon -snapped to the environment boundary and vertices before computing its Visibility_Polygon (use the Point methods snap_to_vertices_of(...) and snap_to_boundary_of(...) ).

Constructor & Destructor Documentation

◆ Visibility_Polygon() [1/2]

VisiLibity::Visibility_Polygon::Visibility_Polygon ( const Point observer,
const Environment environment_temp,
double  epsilon = 0.0 
)

visibility set of a Point in an Environment

Author
Karl J. Obermeyer
Precondition
observer is in environment_temp (w/in epsilon ) and has been epsilon-snapped to the Environment using the method Point::snap_to_boundary_of() followed by (order is important) Point::snap_to_vertices_of(). environment_temp must be epsilon -valid. Test with Environment::is_valid(epsilon).
Remarks
O(n log(n)) average case time complexity, where n is the number of vertices in the Evironment (resp. Polygon).

◆ Visibility_Polygon() [2/2]

VisiLibity::Visibility_Polygon::Visibility_Polygon ( const Point observer,
const Polygon polygon_temp,
double  epsilon = 0.0 
)

visibility set of a Point in a Polygon

Precondition
observer is in polygon_temp (w/in epsilon ) and has been epsilon-snapped to the Polygon using the methods Point::snap_to_vertices_of() and Point::snap_to_boundary_of(). environment_temp must be epsilon -valid. Test with Environment::is_valid(epsilon).
Remarks
less efficient because constructs an Environment from a Polygon and then calls the other Visibility_Polygon constructor. O(n log(n)) average case time complexity, where n is the number of vertices in the Evironment (resp. Polygon).

The documentation for this class was generated from the following files: