Do more simplification in integers

This commit is contained in:
Erica Fischer
2023-07-12 12:18:05 -07:00
parent ee7b68a2cb
commit 8431bd2038
4 changed files with 25 additions and 25 deletions
+6 -6
View File
@@ -980,7 +980,7 @@ drawvec clip_lines(drawvec &geom, long long minx, long long miny, long long maxx
return out;
}
static double square_distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y) {
static long long square_distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y) {
long long p2x = segB_x - segA_x;
long long p2y = segB_y - segA_y;
double something = p2x * p2x + p2y * p2y;
@@ -1027,7 +1027,7 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
int first = recursion_stack.top();
recursion_stack.pop();
double max_distance = -1;
long long max_distance = -1;
int farthest_element_index;
if (geom[start + first] < geom[start + second]) {
farthest_element_index = second;
@@ -1039,9 +1039,9 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
int i;
if (geom[start + first] < geom[start + second]) {
for (i = first + 1; i < second; i++) {
double temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, geom[start + first].x, geom[start + first].y, geom[start + second].x, geom[start + second].y);
long long temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, geom[start + first].x, geom[start + first].y, geom[start + second].x, geom[start + second].y);
double distance = std::fabs(temp_dist);
long long distance = std::llabs(temp_dist);
if ((distance > e || kept < retain) && (distance > max_distance || (distance == max_distance && geom[start + i] < geom[start + farthest_element_index]))) {
farthest_element_index = i;
@@ -1050,9 +1050,9 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
}
} else {
for (i = second - 1; i > first; i--) {
double temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, geom[start + first].x, geom[start + first].y, geom[start + second].x, geom[start + second].y);
long long temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, geom[start + first].x, geom[start + first].y, geom[start + second].x, geom[start + second].y);
double distance = std::fabs(temp_dist);
long long distance = std::llabs(temp_dist);
if ((distance > e || kept < retain) && (distance > max_distance || (distance == max_distance && geom[start + i] < geom[start + farthest_element_index]))) {
farthest_element_index = i;