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

set of Guards represented by a list of Points More...

#include <visilibity.hpp>

Public Member Functions

 Guards ()
 default to empty
 
 Guards (const std::string &filename)
 construct from *.guards file More...
 
 Guards (const std::vector< Point > &positions)
 construct from STL vector of Points
 
const Pointoperator[] (unsigned i) const
 raw access to guard position Points More...
 
unsigned N () const
 guard count
 
bool are_lex_ordered () const
 true iff positions are lexicographically ordered
 
bool noncolocated (double epsilon=0.0) const
 true iff no two guards are w/in epsilon of each other
 
bool in (const Polygon &polygon_temp, double epsilon=0.0) const
 true iff all guards are located in polygon_temp
 
bool in (const Environment &environment_temp, double epsilon=0.0) const
 true iff all guards are located in environment_temp
 
double diameter () const
 Euclidean diameter. More...
 
Bounding_Box bbox () const
 box which fits snugly around the Guards More...
 
void write_to_file (const std::string &filename, int fios_precision_temp=FIOS_PRECISION)
 write list of positions to *.guards file More...
 
Pointoperator[] (unsigned i)
 raw access to guard position Points More...
 
void push_back (const Point &point_temp)
 add a guard
 
void set_positions (const std::vector< Point > &positions_temp)
 set positions with STL vector of Points
 
void enforce_lex_order ()
 sort positions in lexicographic order More...
 
void reverse ()
 reverse order of positions
 
void snap_to_vertices_of (const Environment &environment_temp, double epsilon=0.0)
 relocate each guard to closest vertex if within epsilon of some vertex (of environment_temp) More...
 
void snap_to_vertices_of (const Polygon &polygon_temp, double epsilon=0.0)
 relocate each guard to closest vertex if within epsilon of some vertex (of environment_temp) More...
 
void snap_to_boundary_of (const Environment &environment_temp, double epsilon=0.0)
 relocate each guard to closest Point on boundary if within epsilon of the boundary (of environment_temp) More...
 
void snap_to_boundary_of (const Polygon &polygon_temp, double epsilon=0.0)
 relocate each guard to closest Point on boundary if within epsilon of the boundary (of polygon_temp) More...
 

Private Attributes

std::vector< Pointpositions_
 

Friends

class Visibility_Graph
 

Detailed Description

set of Guards represented by a list of Points

Constructor & Destructor Documentation

◆ Guards()

VisiLibity::Guards::Guards ( const std::string &  filename)

construct from *.guards file

Author
Karl J. Obermeyer

Member Function Documentation

◆ bbox()

Bounding_Box VisiLibity::Guards::bbox ( ) const

box which fits snugly around the Guards

Author
Karl J. Obermeyer
Precondition
greater than 0 guards

◆ diameter()

double VisiLibity::Guards::diameter ( ) const

Euclidean diameter.

Author
Karl J. Obermeyer
Precondition
greater than 0 guards
Returns
maximum Euclidean distance between all pairs of vertices
Remarks
time complexity O(N^2), where N is the number of guards

◆ enforce_lex_order()

void VisiLibity::Guards::enforce_lex_order ( )

sort positions in lexicographic order

from (lowest x, then lowest y) to (highest x, then highest y)

Author
Karl J. Obermeyer
Remarks
time complexity O(N logN), where N is the guard count. Lex. comparison is very sensitive to perturbations if two Points nearly define a line parallel to one of the axes.

◆ operator[]() [1/2]

Point & VisiLibity::Guards::operator[] ( unsigned  i)
inline

raw access to guard position Points

Author
Karl J. Obermeyer
Remarks
for efficiency, no bounds check; usually trying to access out of bounds causes a bus error

◆ operator[]() [2/2]

const Point & VisiLibity::Guards::operator[] ( unsigned  i) const
inline

raw access to guard position Points

Author
Karl J. Obermeyer
Remarks
for efficiency, no bounds check; usually trying to access out of bounds causes a bus error

◆ snap_to_boundary_of() [1/2]

void VisiLibity::Guards::snap_to_boundary_of ( const Environment environment_temp,
double  epsilon = 0.0 
)

relocate each guard to closest Point on boundary if within epsilon of the boundary (of environment_temp)

Author
Karl J. Obermeyer
Precondition
the guards' position data are numbers and environment_temp is nonempty
Postcondition
If the calling Point was a Euclidean distance no greater than epsilon from the boundary of environment_temp, then it will be repositioned to it's projection onto that boundary
Remarks
O(N*n) time complexity, where N is the guard count and n is the number of vertices in environment_temp

◆ snap_to_boundary_of() [2/2]

void VisiLibity::Guards::snap_to_boundary_of ( const Polygon polygon_temp,
double  epsilon = 0.0 
)

relocate each guard to closest Point on boundary if within epsilon of the boundary (of polygon_temp)

Author
Karl J. Obermeyer
Precondition
the guards' position data are numbers and polygon_temp is nonempty
Postcondition
If the calling Point was a Euclidean distance no greater than epsilon from the boundary of polygon_temp, then it will be repositioned to it's projection onto that boundary
Remarks
O(N*n) time complexity, where N is the guard count and n is the number of vertices in polygon_temp

◆ snap_to_vertices_of() [1/2]

void VisiLibity::Guards::snap_to_vertices_of ( const Environment environment_temp,
double  epsilon = 0.0 
)

relocate each guard to closest vertex if within epsilon of some vertex (of environment_temp)

Author
Karl J. Obermeyer
Precondition
the guards' position data are numbers and environment_temp is nonempty
Postcondition
if a guard was a Euclidean distance no greater than epsilon from any vertex of environment_temp, then it will be repositioned to coincide with the closest such vertex
Remarks
O(N*n) time complexity, where N is the guard count and n is the number of vertices in environment_temp.

◆ snap_to_vertices_of() [2/2]

void VisiLibity::Guards::snap_to_vertices_of ( const Polygon polygon_temp,
double  epsilon = 0.0 
)

relocate each guard to closest vertex if within epsilon of some vertex (of environment_temp)

Author
Karl J. Obermeyer
Precondition
the guards' position data are numbers and polygon_temp is nonempty
Postcondition
if a guard was a Euclidean distance no greater than epsilon from any vertex of polygon_temp, then it will be repositioned to coincide with the closest such vertex
Remarks
O(N*n) time complexity, where N is the guard count and n is the number of vertices in polygon_temp

◆ write_to_file()

void VisiLibity::Guards::write_to_file ( const std::string &  filename,
int  fios_precision_temp = FIOS_PRECISION 
)

write list of positions to *.guards file

Uses intuitive human and computer readable decimal format with display precision fios_precision_temp.

Author
Karl J. Obermeyer
Precondition
fios_precision_temp >=1

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