48 return (((a_pt2.x - a_pt1.x) * (a_pt3.y - a_pt1.y)) -
49 ((a_pt3.x - a_pt1.x) * (a_pt2.y - a_pt1.y))) *
79 for (
size_t i = 0; i < a_polys.size(); ++i)
83 size_t numPts = poly.size();
85 for (
size_t j = 0; j < numPts; ++j)
87 pts.push_back(a_points[poly[j]]);
90 points.push_back(centroid);
94 int firstCellCenter = (int)a_points.size();
97 for (
size_t cellIdx = 0; cellIdx < a_polys.size(); ++cellIdx)
100 VecInt& poly = a_polys[cellIdx];
101 size_t numPts = poly.size();
102 for (
size_t pt = 0; pt < numPts; ++pt)
104 newPoly[0] = poly[pt];
105 newPoly[1] = poly[(pt + 1) % numPts];
106 newPoly[2] = firstCellCenter + (int)cellIdx;
107 trianglePolys.push_back(newPoly);
112 a_polys = trianglePolys;
135 for (
int i = 0; i <= rows; ++i)
137 for (
int j = 0; j <= cols; ++j)
139 pts.push_back(
Pt3d(j * 10.0, -i * 10.0, 0.0));
143 polys.assign(rows * cols,
VecInt());
146 int nodeNextRow = cols + 1;
147 for (
int i = 0; i < rows; ++i)
149 for (
int j = 0; j < cols; ++j)
151 VecInt& poly = polys[count++];
152 poly.push_back(node++);
153 poly.push_back(nodeNextRow++);
154 poly.push_back(nodeNextRow);
155 poly.push_back(node);
std::vector< int > VecInt
Functions dealing with triangles.
void trBuildGridPolys(int rows, int cols, VecPt3d &pts, VecInt2d &polys)
Build something like this:
std::vector< VecInt > VecInt2d
Functions dealing with geometry.
double trArea(const Pt3d &a_pt1, const Pt3d &a_pt2, const Pt3d &a_pt3)
Return the signed planar area of the triangle (CCW Positive).
void trBuildGridTrianglePolys(int rows, int cols, VecPt3d &a_points, VecInt2d &a_polys)
Create something like this:
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...
std::vector< Pt3d > VecPt3d