By George, I think she's got it!

This commit is contained in:
Erica Fischer
2023-12-06 16:56:52 -08:00
parent 80c84eb88a
commit 9ae1e575ca
4 changed files with 51 additions and 28 deletions
+21 -27
View File
@@ -17,35 +17,28 @@ drawvec reinforce(drawvec const &pts, std::vector<std::vector<Point>> polygon, d
size_t v2 = i + ((j + 1) % 3);
size_t v3 = i + ((j + 2) % 3);
double px, py;
if (distance_from_line(pts[indices[v1]].x, pts[indices[v1]].y, // the point
pts[indices[v2]].x, pts[indices[v2]].y, // start of opposite side
pts[indices[v3]].x, pts[indices[v3]].y, // end of opposite side
&px, &py) < 2 * scale) {
double ang = atan2(pts[indices[v1]].y - py, pts[indices[v1]].x - px);
// make a new triangle that is not so flat
out2.push_back(draw(VT_MOVETO, pts[indices[v2]].x, pts[indices[v2]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x, pts[indices[v3]].y));
out2.push_back(draw(VT_LINETO, px + scale * 2 * cos(ang), py + scale * 2 * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x, pts[indices[v2]].y));
}
#if 0
long long dx = pts[indices[v2]].x - pts[indices[v1]].x;
long long dy = pts[indices[v2]].y - pts[indices[v1]].y;
double d = sqrt(dx * dx + dy * dy);
if (d < sqrt(2) * scale) {
// make a new triangle with a longer side
double ang = atan2(dy, dx);
out2.push_back(draw(VT_MOVETO, pts[indices[v3]].x, pts[indices[v3]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v1]].x - sqrt(2) * scale * cos(ang), pts[indices[v1]].y - sqrt(2) * scale * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x + sqrt(2) * scale * cos(ang), pts[indices[v2]].y + sqrt(2) * scale * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x, pts[indices[v3]].y));
}
out2.push_back(draw(VT_MOVETO, pts[indices[v1]].x, pts[indices[v1]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x, pts[indices[v2]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x, pts[indices[v3]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v1]].x, pts[indices[v1]].y));
#endif
double px, py;
double d = distance_from_line_noclamp(pts[indices[v1]].x, pts[indices[v1]].y,
pts[indices[v2]].x, pts[indices[v2]].y,
pts[indices[v3]].x, pts[indices[v3]].y,
&px, &py);
if (d < scale) {
double ang = atan2(py - pts[indices[v1]].y, px - pts[indices[v1]].x);
double dist = scale - d;
out2.push_back(draw(VT_MOVETO, pts[indices[v1]].x, pts[indices[v1]].y));
out2.push_back(draw(VT_LINETO, pts[indices[v2]].x + dist * cos(ang), pts[indices[v2]].y + dist * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v3]].x + dist * cos(ang), pts[indices[v3]].y + dist * sin(ang)));
out2.push_back(draw(VT_LINETO, pts[indices[v1]].x, pts[indices[v1]].y));
}
}
}
@@ -95,6 +88,7 @@ drawvec fix_by_triangulation(drawvec const &dv, int z, int detail) {
for (auto const &d : additional) {
out2.push_back(d);
}
for (auto const &d : dv) {
out2.push_back(d);
}