GeoTessCPP: geotess::Polygon3D Class Reference

GeoTessCPP 2.0.0 Software to facilitate storage and retrieval of 3D information about the Earth.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions
geotess::Polygon3D Class Reference

`#include <Polygon3D.h>`

Inheritance diagram for geotess::Polygon3D:

List of all members.

## Public Member Functions
| ~Polygon3D ()
| Polygon3D ()
| Polygon3D (vector< double * > points, Horizon *h_bottom, Horizon *h_top)
| Polygon3D (double *center, double radius, int nEdges, Horizon *h_bottom, Horizon *h_top)
| Polygon3D (string filename)
virtual string | class_name ()
Horizon * | getTop ()
Horizon * | getBottom ()
bool | contains (const double *x)
bool | contains (const double *x, const double &radius, const int &layer, Profile **profiles)
bool | contains (const double *x, const int &layer)
bool | containsAll (vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< Profile ** > &profiles)
bool | containsAny (vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< Profile ** > &profiles)
virtual void | write (const string &outputFileName)
Public Member Functions inherited from geotess::Polygon
virtual | ~Polygon ()
| Polygon ()
| Polygon (vector< double * > &points)
| Polygon (const double *center, double radius, int nEdges)
| Polygon (string filename)
void | addReference ()
void | removeReference ()
bool | isNotReferenced ()
int | size ()
const double *const | getReferencePoint ()
const void | getReferencePoint (double *u)
bool | getReferencePointIn ()
void | invert ()
void | setReferencePoint (const double *refPoint, const bool &inside)
void | setReferencePoint (double lat, double lon, bool inside)
bool | containsAny (const vector< double * > &points)
bool | containsAll (const vector< double * > &positions)
bool | onBoundary (GreatCircle &gcRef)
bool | onBoundary (const double *x)
void | getPoints (vector< double * > &points, const bool &repeatFirstPoint)
void | getPoints (vector< double * > &points, const bool &repeatFirstPoint, const double &maxSpacing)
const double * | getPoint (int index)
double | getArea ()
double | getAreaSmall ()
double | getAreaLarge ()
string | str (const bool &repeatFirstPoint, const bool &latFirst, const double &minLongitude=-180)

## Additional Inherited Members
Static Public Member Functions inherited from geotess::Polygon
static double | getTolerance ()
Public Attributes inherited from geotess::Polygon
void * | attachment
Protected Member Functions inherited from geotess::Polygon
void | setup (vector< double * > &points)
int | edgeCrossings (GreatCircle &gcRef)
Protected Attributes inherited from geotess::Polygon
vector< GreatCircle * > | edges
double * | referencePoint
bool | referenceIn
bool | global
bool | lonFirst
int | refCount
Static Protected Attributes inherited from geotess::Polygon
static double | TOLERANCE

## Detailed Description

An ordered list of points on the surface of a unit sphere that define a closed polygon. Polygons have the ability to test whether or not an arbitrary test point on the sphere is inside or outside the polygon.

Besides the set of points that define the boundary of the polgon, a Polygon object has a single private instance of a reference point which is known to be either 'inside' or 'outside' the polygon. By default, the reference point is computed from the supplied boundary points in the following manner:

- Compute the normalized vector mean of all the points that define the polygon and call it center.
- set the referencePoint to the anti-pode of center.
- set referencePointIn to false
- test center to see if it is inside or outside the polygon and set the value of referencePointIn to this value.
- change the value of referencePoint to center

This method will work fine provided that polygons are 'smaller' than approximately a hemisphere. It is possible to override this behavior. The first method is to call the invert() method which simply reverses the value of whether the reference point is 'inside' or 'outside' the polygon. There are also methods that allow applications to specify both the position of the reference point and whether it is 'inside' or 'outside' the polygon.

A convenient mechanism for generating polygons is to use Google Earth. It has the ability to interactively generate polygons and store them in kmz or kml files. Polygon has facilities to read (but not write) these files. Polygon can also read and write polygons to an ascii file. An advantage of the ascii file format is that the position of the reference point and whether the reference point is inside or outside the polygon are stored in the file and therefore can be manipulated by users. For example, if a user wishes to generate a polygon that is larger than a hemisphere, they could define the polygon boundary points with Google Earth but the resulting polygon would be inverted (the inside would be outside and the outside would be inside). They could use Polygon to write the polygon to an ascii file,and manually edit the file to modify the reference point definition.

A test point that is located very close to a polygon boundary point is deemed to be 'inside' the polygon. This means that if two adjacent, non-overlapping polygons share a boundary point, a test point near that boundary point will be deemed to be 'inside' both polygons. In this context two points are 'very close' if they are separated by less than 1e-7 radians or 5.7e-6 degrees. For a sphere with the radius of the Earth (6371 km), this corresponds to a linear distance of about 60 cm.

Author:
  sballar

## Constructor & Destructor Documentation

geotess::Polygon3D::~Polygon3D | ( |  | ) |

geotess::Polygon3D::Polygon3D | ( |  | ) |
| inline

geotess::Polygon3D::Polygon3D | ( | vector< double * > | points,
|  | Horizon * | h_bottom,
|  | Horizon * | h_top
| ) |  |
| inline

Constructor that accepts a list of unit vectors that define the polygon. The polygon will be closed, i.e., if the first point and last point are not coincident then an edge will be created between them.

Parameters:

  points | array of unit vectors specifying the positions that define the polygon.
  h_bottom | Horizon object that defines the bottom of the Polygon3D.
  h_top | Horizon object that defines the top of the Polygon3D.

geotess::Polygon3D::Polygon3D | ( | double * | center,
|  | double | radius,
|  | int | nEdges,
|  | Horizon * | h_bottom,
|  | Horizon * | h_top
| ) |  |
| inline

Constructor that builds a circular polygon of a specified horizontal radius centered on position center.

Parameters:

  center | unit vector of the position that defines the center of the circular Polygon.
  radius | angular radius of the polygon, in radians.
  nEdges | number of edges that define the polygon
  h_bottom | Horizon object that defines the bottom of the Polygon3D.
  h_top | Horizon object that defines the top of the Polygon3D.

geotess::Polygon3D::Polygon3D | ( | string | filename | ) |

Constructor that reads a Polygon from a file.

Parameters:

  filename | the name of the file containing the polygon information.

throws a GeoTessException if specified file is a kml or kmz file. GeoTessExplorer can translate kml/kmz files to a compatible ascii format.

## Member Function Documentation

virtual string geotess::Polygon3D::class_name | ( |  | ) |
| inlinevirtual

Returns the class name.

Reimplemented from geotess::Polygon.

bool geotess::Polygon3D::contains | ( | const double * | x | ) |
| inline

return true if point x is located inside the polygon

Parameters:

  x | unit vector of position to be evaluated

Returns:
  true if point x is located inside the polygon

Reimplemented from geotess::Polygon.

bool geotess::Polygon3D::contains | ( | const double * | x,
|  | const double & | radius,
|  | const int & | layer,
|  | Profile ** | profiles
| ) |  |
| inline

bool geotess::Polygon3D::contains | ( | const double * | x,
|  | const int & | layer
| ) |  |
| inline

bool geotess::Polygon3D::containsAll | ( | vector< double * > & | points,
|  | vector< double > & | radii,
|  | vector< int > & | layers,
|  | vector< Profile ** > & | profiles
| ) |  |
| inline

Returns true if this Polygon contains all of the supplied unit vectors

Parameters:

  points | unit vectors of positions to be evaluated
  radii | the radii of the positions to be evaluated. radii.size() and points.size() must be equal.
  layers | the indexes of the layers in which the positions reside.
  profiles | the array of Profiles at the current geographic position. profiles.size() must equal number of layers in the model.

Returns:
  true if this Polygon contains all of the supplied unit vectors

bool geotess::Polygon3D::containsAny | ( | vector< double * > & | points,
|  | vector< double > & | radii,
|  | vector< int > & | layers,
|  | vector< Profile ** > & | profiles
| ) |  |
| inline

Returns true if this Polygon contains any of the supplied unit vectors

Parameters:

  points | unit vectors of positions to be evaluated
  radii | the radii of the positions to be evaluated. radii.size() and points.size() must be equal.
  layers | the indexes of the layers in which the positions reside.
  profiles | the array of Profiles at the current geographic position. profiles.size() must equal number of layers in the model.

Returns:
  true if this Polygon contains any of the supplied unit vectors

Horizon* geotess::Polygon3D::getBottom | ( |  | ) |
| inline

Retrieve a reference to the Horizon that defines the bottom of the active region.

Horizon* geotess::Polygon3D::getTop | ( |  | ) |
| inline

Retrieve a reference to the Horizon that defines the top of the active region.

virtual void geotess::Polygon3D::write | ( | const string & | outputFileName | ) |
| virtual

Reimplemented from geotess::Polygon.

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

- include/Polygon3D.h