More cleanup (#1568, #1569, # 1570, #1571)

This commit is contained in:
be5invis 2023-02-26 06:40:11 -08:00
parent c5d322709a
commit e5178514c7
5 changed files with 36 additions and 31 deletions

View file

@ -359,7 +359,7 @@ class CoordinateAligner {
}
apply() {
for (let i = 0; i < this.c.length; i++) {
this.lensSet(this.c[i], this.lens(this.c[this.find(i)]));
this.lensSet(this.c[i], Math.round(this.lens(this.c[this.find(i)])));
}
}
}
@ -379,12 +379,11 @@ function occurrentPrecisionEqual(a, b) {
function aligned(a, b, c) {
return a === b && b === c;
}
function between(a, b, c) {
return (a <= b && b <= c) || (a >= b && b >= c);
}
function pointsColinear(zPrev, zCurr, zNext) {
if (aligned(zPrev.x, zCurr.x, zNext.x) && between(zPrev.y, zCurr.y, zNext.y)) return true;
if (aligned(zPrev.y, zCurr.y, zNext.y) && between(zPrev.x, zCurr.x, zNext.x)) return true;
// No need to check in-betweenness, we can safely remove the corner
if (aligned(zPrev.x, zCurr.x, zNext.x)) return true;
if (aligned(zPrev.y, zCurr.y, zNext.y)) return true;
return false;
}