xmsgrid
1.0
|
Functions dealing with geometry. More...
#include <xmsgrid/geometry/geoms.h>
#include <cfloat>
#include <algorithm>
#include <xmscore/math/math.h>
#include <xmscore/misc/XmError.h>
#include <xmscore/points/pt.h>
#include <xmscore/stl/vector.h>
#include <xmsgrid/geometry/GmPolygon.h>
#include <xmscore/misc/xmstype.h>
#include <xmsgrid/triangulate/triangles.h>
#include <xmscore/misc/XmConst.h>
#include <boost/timer/timer.hpp>
#include <xmscore/testing/TestTools.h>
#include <xmsgrid/geometry/GmPolygon.t.h>
#include <xmsgrid/geometry/geoms.t.h>
#include <xmscore/misc/XmLog.h>
Go to the source code of this file.
Classes | |
class | GmPointInPolyTester_gmPointInPolygon2D |
For testing point in polygon speed. More... | |
Namespaces | |
xms | |
XMS Namespace. | |
Functions | |
bool | xms::gmPointInOrOnBox2d (const Pt3d &a_bMin, const Pt3d &a_bMax, const Pt3d &a_pt) |
finds if a point is in or on a box in 2d More... | |
bool | xms::gmBoxesOverlap2d (const Pt3d &a_b1Min, const Pt3d &a_b1Max, const Pt3d &a_b2Min, const Pt3d &a_b2Max) |
finds if 2 boxes overlap in 2d More... | |
void | xms::gmCalculateNormalizedPlaneCoefficients (const Pt3d &p1, const Pt3d &p2, const Pt3d &p3, double *a, double *b, double *c, double *d) |
Calculates the plane coefficients for a triangle. Given point references calculate coefficents for plane (ax+by+cz+d=0). More... | |
void | xms::gmCalculateNormalizedPlaneCoefficients (const Pt3d *p1, const Pt3d *p2, const Pt3d *p3, double *a, double *b, double *c, double *d) |
Calculates the plane coefficients for a triangle. Given point pointers calculate coefficents for plane (ax+by+cz+d=0). More... | |
double | xms::gmMiddleZ (const VecPt3d &a_points) |
Returns the z value halfway between the max and min z. Different from the average z (where many points can skew the average). More... | |
PtInOutOrOn_enum | xms::gmPtInCircumcircle (const Pt3d &pt, Pt3d circumcirclePts[3]) |
Is a given point inside a circumcircle defined by three points? More... | |
double | xms::gmXyDistanceSquared (const Pt3d &pt1, const Pt3d &pt2) |
Calculate XY distance between two 3D points. More... | |
bool | xms::gmCircumcircleWithTol (const Pt3d *pt1, const Pt3d *pt2, const Pt3d *pt3, double *xc, double *yc, double *r2, double tol) |
Computes center & radius squared for circumcircle of triangle made by the three points. More... | |
int | xms::gmCartToBary (const Pt3d *cart, const Pt3d *orig, double coef[6], int dir, Pt3d *bary) |
Compute Barycentric coords for point. Use gmBaryPrepare to get the coefficients and direction. More... | |
int | xms::gmBaryPrepare (const Pt3d *p1, const Pt3d *p2, const Pt3d *p3, const Pt3d *norm, Pt3d *orig, double coef[6], int *dir, bool flag) |
For a tri - compute dir & coefs to compute Barycentric coords. More... | |
bool | xms::gmColinearWithTol (const Pt3d &p1, const Pt3d &p2, const Pt3d &p3, const double tol) |
Returns true if (the three vertices are gmColinear. Result should be insensitive to the order of the vertices. More... | |
bool | xms::gmIntersectLineSegmentsWithTol (const Pt3d &one1, const Pt3d &one2, const Pt3d &two1, const Pt3d &two2, double *xi, double *yi, double *zi1, double *zi2, double tol) |
Intersects the plan projection of two line segments. More... | |
bool | xms::gmCounterClockwiseTri (const Pt3d &vtx0, const Pt3d &vtx1, const Pt3d &vtx2) |
Returns true if the triangle is wrapped counter clockwise. More... | |
double | xms::gmCross2D (const double &dx1, const double &dy1, const double &dx2, const double &dy2) |
Returns the cross product of two 2-d vectors. More... | |
double | xms::gmCross2D (const Pt3d &a_origin, const Pt3d &a_A, const Pt3d &a_B) |
2D cross product of two points More... | |
double | xms::gmAngleBetween2DVectors (double dxp, double dyp, double dxn, double dyn) |
Returns the angle (0-2PI) in radians between the edges p and n based on a ccw rotation from p to n. More... | |
double | xms::gmAngleBetween2DVectors (double dxp, double dyp, double dxn, double dyn, double a_magn, double a_magp) |
Returns the angle (0-2PI) in radians between the edges p and n based on a ccw rotation from p to n. More... | |
double | xms::gmAngleBetweenEdges (const Pt3d &p1, const Pt3d &p2, const Pt3d &p3) |
Returns the ccw angle (0-2pi) between p2-p1 and p2-p3. More... | |
double | xms::gmAngleBetweenEdges (const Pt2d &p1, const Pt2d &p2, const Pt2d &p3) |
Returns the ccw angle (0-2pi) between p2-p1 and p2-p3. More... | |
double | xms::gmComputeDeviationInDirection (const Pt3d &a_p0, const Pt3d &a_p1, const Pt3d &a_p2) |
Computes the deviation in direction from one seg to next seg 1 is from a_p0 to a_p1 seg 2 is from a_p1 to a_p2. More... | |
bool | xms::gmOnLineWithTol (const Pt3d &p1, const Pt3d &p2, const double x, const double y, const double tol) |
Determines if a point (x,y) is on the line defined by p1 and p2. Assumes p1 and p2 aren't the same. More... | |
bool | xms::gmOnLineAndBetweenEndpointsWithTol (const Pt3d &a_pt1, const Pt3d &a_pt2, const double a_x, const double a_y, double a_tol) |
determines if (x,y) is on the line passing through p1 & p2 and between p1 & p2. More... | |
void | xms::gmAddToExtents (const Pt3d &a_pt, Pt3d &a_min, Pt3d &a_max) |
Compares a_pt to a_min and a_max. If a_pt is less than a_min or greater than a_max, a_min and a_max are updated. More... | |
void | xms::gmAddToExtents (const Pt3d &a_pt, Pt2d &a_min, Pt2d &a_max) |
void | xms::gmAddToExtents (const Pt2d &a_pt, Pt3d &a_min, Pt3d &a_max) |
double | xms::gmXyDistance (double x1, double y1, double x2, double y2) |
Compute the 2d distance between 2 points. More... | |
double | xms::gmXyDistance (const Pt3d &pt1, const Pt3d &pt2) |
Turn_enum | xms::gmTurn (const Pt3d &a_v1, const Pt3d &a_v2, const Pt3d &a_v3, double a_angtol) |
Determine if angle a_v1, a_v2, a_v3 is a left turn, a right turn, colinear 180 degrees, or colinear 0 degrees. More... | |
Pt3d | xms::gmComputeCentroid (const VecPt3d &a_points) |
Computes the centroid of points (but not of a polygon). Shouldn't pass an empty vector (no checks are performed). More... | |
Pt3d | xms::gmComputePolygonCentroid (const VecPt3d &pts) |
Computes the plan view centroid of a non-self-intersecting polygon. More... | |
bool | xms::gmLinesIntersect (const Pt3d &one1, const Pt3d &one2, const Pt3d &two1, const Pt3d &two2) |
intersects the plan projection of two line segments (bad func name) segment 1 = one1,one2 = one1 + lambda(one2 - one1) segment 2 = two1,two2 = two1 + mu (two2 - two1) More... | |
bool | xms::gmLinesCross (const Pt3d &a_segment1Point1, const Pt3d &a_segment1Point2, const Pt3d &a_segment2Point1, const Pt3d &a_segment2Point2) |
Determine whether 2 line segments cross. The segments may touch at the end points. More... | |
template<typename T > | |
int | xms::gmPointInPolygon2D (const T *a_verts, const size_t a_num, const double a_x, const double a_y, const double a_tol) |
Determines whether (a_x, a_y) is inside=1, on=0, or outside=-1 the polygon defined by the given vertices. More... | |
int | xms::gmPointInPolygon2D (const Pt3d *a_verts, size_t a_num, double a_x, double a_y) |
int | xms::gmPointInPolygon2D (const Pt3d *a_verts, size_t a_num, Pt3d a_pt) |
int | xms::gmPointInPolygon2D (const Pt2i *a_verts, size_t a_num, Pt2d a_pt) |
int | xms::gmPointInPolygon2D (const Pt2i *a_verts, size_t a_num, Pt3d a_pt) |
int | xms::gmPointInPolygon2D (const Pt2i *a_verts, size_t a_num, Pt2i a_pt) |
int | xms::gmPointInPolygon2D (const VecPt3d &a_verts, const Pt3d &a_pt) |
template int | xms::gmPointInPolygon2D< Pt3d > (const Pt3d *a_verts, const size_t a_num, const double a_x, const double a_y, const double a_tol) |
template int | xms::gmPointInPolygon2D< Pt2d > (const Pt2d *a_verts, const size_t a_num, const double a_x, const double a_y, const double a_tol) |
template int | xms::gmPointInPolygon2D< Pt2i > (const Pt2i *a_verts, const size_t a_num, const double a_x, const double a_y, const double a_tol) |
double | xms::gmComputeXyTol (const Pt3d &a_mn, const Pt3d &a_mx) |
Given extents (min, max), compute a tolerance for the xy plane to be used with geometric functions. More... | |
double | xms::gmXyTol (bool a_set, double a_value) |
Get or set (set first time) global xy tolerance for float operations. More... | |
double | xms::gmZTol (bool a_set, double a_value) |
Get or set (set first time) global z tolerance for float operations. More... | |
bool | xms::gmEqualPointsXY (double x1, double y1, double x2, double y2, double tolerance) |
Returns true if the points are equal to within gmXyTol(). More... | |
bool | xms::gmEqualPointsXY (double x1, double y1, double x2, double y2) |
bool | xms::gmEqualPointsXY (const Pt2d &a_pt1, const Pt2d &a_pt2, double tol) |
bool | xms::gmEqualPointsXY (const Pt3d &a_pt1, const Pt3d &a_pt2, double tol) |
bool | xms::gmEqualPointsXY (const Pt2i &point1, const Pt2i &point2) |
bool | xms::gmEqualPointsXYZ (double x1, double y1, double z1, double x2, double y2, double z2, double tolerance) |
Returns true if the points are equal to within tolerance. More... | |
bool | xms::gmEqualPointsXYZ (double x1, double y1, double z1, double x2, double y2, double z2) |
bool | xms::gmEqualPointsXYZ (const Pt3d &pt1, const Pt3d &pt2, double tol) |
bool | xms::gmPointInTriangleWithTol (const Pt3d *p1, const Pt3d *p2, const Pt3d *p3, double x, double y, double tol) |
Returns true if (x,y) is in the tri formed by p1, p2, p3. More... | |
bool | xms::gmInsideOrOnLineWithTol (const Pt3d *p1, const Pt3d *p2, const Pt3d *inpoint, const double x, const double y, const double tol, double *dist) |
Returns true if the (x,y) is on the line segment (p1,p2) or on the same side of the line as "inpoint". ASSERTs in debug if "inpoint" is on the line (within tol). More... | |
double | xms::gmPolygonArea (const Pt3d *pts, size_t npoints) |
Compute 2d planview projection of area of polygon. More... | |
VecPt3d | xms::gmArrayToVecPt3d (double *a_array, int a_size) |
Useful in testing to create a VecPt3d from a C array of xy pairs. More... | |
void | xms::gmEnvelopeOfPts (const VecPt3d &a_pts, Pt3d &a_min, Pt3d &a_max) |
Calculates the envelope of a vector of points. More... | |
void | xms::gmOrderPointsCounterclockwise (const VecPt3d &a_pts, VecInt &a_ccwOrder, int a_startindex) |
Orders array of points counter clockwise. Given non-empty array of points. array of point indices ordered counter clockwise based on the angle from the centroid where angle starts at point at startindex. More... | |
void | xms::gmOrderPointsCounterclockwise (VecPt3d &a_pts) |
Overload to gmOrderPointsCounterclockwise. More... | |
double | xms::gmFindClosestPtOnSegment (const Pt3d &a_pt1, const Pt3d &a_pt2, const Pt3d &a_pt, Pt3d &a_newpt, const double a_tol) |
Finds the closest point to another point on a segment. More... | |
double | xms::gmPtDistanceAlongSegment (const Pt3d &a_pt1, const Pt3d &a_pt2, const Pt3d &a_pt, const double a_tol) |
Finds the distance along a segment for the location closest to a_pt. More... | |
bool | xms::gmInsideOfLineWithTol (const Pt3d &a_vertex1, const Pt3d &a_vertex2, const Pt3d &a_oppositevertex, const double a_x, const double a_y, const double a_tol) |
Returns TRUE if the Point on the same side of the line (defined by vertex1 and vertex2) as oppositevertex. More... | |
void | xms::gmExtents2D (const VecPt3d &a_points, Pt2d &a_min, Pt2d &a_max) |
Get the 2D extents of a vector of points. More... | |
void | xms::gmExtents2D (const VecPt3d &a_points, Pt3d &a_min, Pt3d &a_max) |
void | xms::gmExtents3D (const VecPt3d &a_points, Pt3d &a_min, Pt3d &a_max) |
Get the 3D extents of a vector of points. More... | |
double | xms::gmPerpendicularAngle (const Pt3d &a_pt1, const Pt3d &a_pt2) |
Returns the angle in radians perpendicular to the two points. More... | |
double | xms::gmBisectingAngle (const Pt3d &a_p1, const Pt3d &a_p2, const Pt3d &a_p3) |
Returns the angle (0-2pi) which bisects the edges p2-p1 and p2-p3 based on a ccw rotation from edge 1 to edge 2. More... | |
void | xms::gmComponentMagnitudes (double *a_x, double *a_y, double *a_mag, double *a_dir, bool a_tomagdir) |
converts the magnitude and angle to xy components or vice versa More... | |
Pt3d | xms::gmCreateVector (const Pt3d &a_p1, const Pt3d &a_p2) |
creates a vector from a_p1 to a_p2 More... | |
double | xms::gmConvertAngleToBetween0And360 (double a_angle, bool a_InDegrees) |
given an angle, this function will return the corresponding angle that matches it in the range of 0 deg to 360 deg More... | |
void | xms::gmCross3D (const Pt3d &a_vec1, const Pt3d &a_vec2, Pt3d *a_vec3) |
Perform a cross product of Pt3d's. More... | |
double | xms::gmDot3D (const Pt3d &a_vec1, const Pt3d &a_vec2) |
Perform a dot product of Pt3d's. More... | |
int | xms::gmIntersectTriangleAndLineSegment (const Pt3d &a_pt1, const Pt3d &a_pt2, const Pt3d &a_t0, const Pt3d &a_t1, const Pt3d &a_t2, Pt3d &a_IntersectPt) |
Determine if the line (described by a_pt1 and a_pt2) intersects the triangle (a_t0, a_t1, a_t2). More... | |
double | xms::gm2DDistanceToLineWithTol (const Pt3d *a_pt1, const Pt3d *a_pt2, double a_x, double a_y, double a_tol) |
return the xy distance from (a_x,a_y) to line through (a_pt1, a_pt2) More... | |
void | xms::gmGetConvexHull (const VecPt3d &a_pts, VecPt3d &a_hull, bool a_includeOn) |
Calculate convex hull using Monotone chain aka Andrew's algorithm. More... | |
Functions dealing with geometry.
Definition in file geoms.cpp.