96 double gmCross2D(
const double& dx1,
const double& dy1,
const double& dx2,
const double& dy2);
121 double gmXyDistance(
double x1,
double y1,
double x2,
double y2);
135 template <
typename T>
137 const size_t numverts,
142 double gmXyTol(
bool a_set =
false,
double a_value = 1e-9);
143 double gmZTol(
bool a_set =
false,
double a_value = 1e-6);
145 bool gmEqualPointsXY(
double x1,
double y1,
double x2,
double y2,
double tol);
149 bool gmEqualPointsXYZ(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2);
150 bool gmEqualPointsXYZ(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2,
double tol);
164 double* dist = NULL);
177 const Pt3d& a_vertex2,
178 const Pt3d& a_oppositevertex,
197 Pt3d& a_IntersectPt);
double gmMiddleZ(const VecPt3d &a_points)
Returns the z value halfway between the max and min z. Different from the average z (where many point...
bool 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...
double gmZTol(bool a_set, double a_value)
Get or set (set first time) global z tolerance for float operations.
bool 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 oppositeve...
double 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...
std::vector< int > VecInt
void 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 ord...
double gmXyDistance(double x1, double y1, double x2, double y2)
Compute the 2d distance between 2 points.
bool 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.
bool 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.
PtInOutOrOn_enum gmPtInCircumcircle(const Pt3d &pt, Pt3d circumcirclePts[3])
Is a given point inside a circumcircle defined by three points?
double gmPerpendicularAngle(const Pt3d &a_pt1, const Pt3d &a_pt2)
Returns the angle in radians perpendicular to the two points.
bool gmEqualPointsXY(double x1, double y1, double x2, double y2, double tolerance)
Returns true if the points are equal to within gmXyTol().
Turn_enum 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.
double 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...
bool 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.
void gmGetConvexHull(const VecPt3d &a_pts, VecPt3d &a_hull, bool a_includeOn)
Calculate convex hull using Monotone chain aka Andrew's algorithm.
turns back on same segment
void gmEnvelopeOfPts(const VecPt3d &a_pts, Pt3d &a_min, Pt3d &a_max)
Calculates the envelope of a vector of points.
PtInOutOrOn_enum
point in, out, or on
Pt3d gmCreateVector(const Pt3d &a_p1, const Pt3d &a_p2)
creates a vector from a_p1 to a_p2
bool 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"...
bool 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 ...
double 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.
double gmAngleBetweenEdges(const Pt3d &p1, const Pt3d &p2, const Pt3d &p3)
Returns the ccw angle (0-2pi) between p2-p1 and p2-p3.
VecPt3d gmArrayToVecPt3d(double *a_array, int a_size)
Useful in testing to create a VecPt3d from a C array of xy pairs.
double gmPolygonArea(const Pt3d *pts, size_t npoints)
Compute 2d planview projection of area of polygon.
void 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 pl...
bool 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)
void 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
double 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_p...
void gmCross3D(const Pt3d &a_vec1, const Pt3d &a_vec2, Pt3d *a_vec3)
Perform a cross product of Pt3d's.
double 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...
Pt3d gmComputeCentroid(const VecPt3d &a_points)
Computes the centroid of points (but not of a polygon). Shouldn't pass an empty vector (no checks are...
double 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)
double gmXyTol(bool a_set, double a_value)
Get or set (set first time) global xy tolerance for float operations.
double 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 d...
bool 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.
double gmCross2D(const double &dx1, const double &dy1, const double &dx2, const double &dy2)
Returns the cross product of two 2-d vectors.
double 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.
bool 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.
bool 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.
int 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).
Turn_enum
direction of turn between 3 points
bool 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
void 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.
bool gmCounterClockwiseTri(const Pt3d &vtx0, const Pt3d &vtx1, const Pt3d &vtx2)
Returns true if the triangle is wrapped counter clockwise.
double gmDot3D(const Pt3d &a_vec1, const Pt3d &a_vec2)
Perform a dot product of Pt3d's.
bool gmBoxesOverlap2d(const Pt3d &a_b1Min, const Pt3d &a_b1Max, const Pt3d &a_b2Min, const Pt3d &a_b2Max)
finds if 2 boxes overlap in 2d
void gmExtents2D(const VecPt3d &a_points, Pt2d &a_min, Pt2d &a_max)
Get the 2D extents of a vector of points.
int 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 verti...
int 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...
int 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.
void gmExtents3D(const VecPt3d &a_points, Pt3d &a_min, Pt3d &a_max)
Get the 3D extents of a vector of points.
Pt3d gmComputePolygonCentroid(const VecPt3d &pts)
Computes the plan view centroid of a non-self-intersecting polygon.
double gmXyDistanceSquared(const Pt3d &pt1, const Pt3d &pt2)
Calculate XY distance between two 3D points.
std::vector< Pt3d > VecPt3d