$search
#include <SPolygon.hh>
Public Member Functions | |
double | Area () |
void | CenterOfGravity () |
void | Clear () |
void | Expand (double d) |
void | Insert (Vector2 &p) |
bool | Inside (Vector2 &p) |
bool | Inside (double x, double y) |
void | Move (Vector2 &dist) |
Move the whole polygon (and center) by dist. | |
unsigned | NumVertices () |
bool | OnContour (double x, double y, double eps) |
SPolygon & | operator= (const SPolygon &p) |
Vector2 & | operator[] (unsigned i) |
void | PushBack (Vector2 &p) |
void | SetConvexHull (Array< Vector2 > &p) |
unsigned | Size () |
SPolygon (Array< Vector2 > &p) | |
SPolygon () | |
~SPolygon () | |
Static Public Member Functions | |
static double | Area (Array< Vector2 > &vs) |
Calculate area of polygon. | |
static void | CenterOfGravity (Array< Vector2 > &vs, Vector2 &vc) |
Calculate center of gravity. | |
static bool | Inside (Array< Vector2 > &vs, Vector2 &p) |
static void | Load (ifstream &is, SPolygon &p) |
static double | Match (Array< Vector2 > &vs1, Array< Vector2 > &vs2) |
Match two polygons using Hausdorff distance. | |
static double | NearestLine (Vector2 &p, Array< Vector2 > &vs, unsigned &id) |
static double | NearestNeighbour (Vector2 &p, Array< Vector2 > &vs, unsigned &id) |
static void | Save (ofstream &os, const SPolygon &p) |
Public Attributes | |
Vector2 | center |
unsigned | p |
Array< Vector2 > | v |
Definition at line 25 of file SPolygon.hh.
P::SPolygon::SPolygon | ( | ) |
Definition at line 18 of file SPolygon.cc.
Definition at line 34 of file SPolygon.cc.
P::SPolygon::~SPolygon | ( | ) | [inline] |
Definition at line 37 of file SPolygon.hh.
Calculate area of polygon.
Definition at line 242 of file SPolygon.cc.
double P::SPolygon::Area | ( | ) | [inline] |
Definition at line 49 of file SPolygon.hh.
Calculate center of gravity.
Definition at line 228 of file SPolygon.cc.
void P::SPolygon::CenterOfGravity | ( | ) | [inline] |
Definition at line 67 of file SPolygon.hh.
void P::SPolygon::Clear | ( | ) | [inline] |
Definition at line 43 of file SPolygon.hh.
void P::SPolygon::Expand | ( | double | d | ) |
Definition at line 58 of file SPolygon.cc.
void P::SPolygon::Insert | ( | Vector2 & | p | ) | [inline] |
Definition at line 47 of file SPolygon.hh.
Definition at line 138 of file SPolygon.cc.
bool P::SPolygon::Inside | ( | Vector2 & | p | ) | [inline] |
Definition at line 42 of file SPolygon.hh.
bool P::SPolygon::Inside | ( | double | x, | |
double | y | |||
) |
Checks whether point p is inside polygon. Uses the Jordan curve theorem. Note that points on the boundary are undefined. Code thanks to W Randolph Franklin (WRF) http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html int pnpoly(int npol, float *xp, float *yp, float x, float y) { int i, j, c = 0; for (i = 0, j = npol-1; i < npol; j = i++) { if ((((yp[i]<=y) && (y<yp[j])) || ((yp[j]<=y) && (y<yp[i]))) && (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
c = !c; } return c; }
Definition at line 114 of file SPolygon.cc.
void P::SPolygon::Load | ( | ifstream & | is, | |
SPolygon & | p | |||
) | [static] |
Definition at line 276 of file SPolygon.cc.
Match two polygons using Hausdorff distance.
Definition at line 195 of file SPolygon.cc.
void P::SPolygon::Move | ( | Vector2 & | dist | ) | [inline] |
Move the whole polygon (and center) by dist.
Definition at line 80 of file SPolygon.hh.
search for nearest line to point (normal length between two end points)
Definition at line 171 of file SPolygon.cc.
search for nearest neighbour of a point in 2d
Definition at line 155 of file SPolygon.cc.
unsigned P::SPolygon::NumVertices | ( | ) | [inline] |
Definition at line 46 of file SPolygon.hh.
bool P::SPolygon::OnContour | ( | double | x, | |
double | y, | |||
double | eps | |||
) |
Definition at line 128 of file SPolygon.cc.
Definition at line 41 of file SPolygon.cc.
Vector2& P::SPolygon::operator[] | ( | unsigned | i | ) | [inline] |
Definition at line 62 of file SPolygon.hh.
void P::SPolygon::PushBack | ( | Vector2 & | p | ) | [inline] |
Definition at line 45 of file SPolygon.hh.
void P::SPolygon::Save | ( | ofstream & | os, | |
const SPolygon & | p | |||
) | [static] |
Definition at line 265 of file SPolygon.cc.
SetConvexHull Calculates the convex hull of p
Definition at line 53 of file SPolygon.cc.
unsigned P::SPolygon::Size | ( | ) | [inline] |
Definition at line 44 of file SPolygon.hh.
Definition at line 29 of file SPolygon.hh.
unsigned P::SPolygon::p |
Definition at line 30 of file SPolygon.hh.
Definition at line 28 of file SPolygon.hh.