Skip to content

Commit 275ca3a

Browse files
authored
Refactor bisector direction logic in query_utils
Refactor bisector direction calculation to avoid duplicate points.
1 parent 2939e0c commit 275ca3a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/style/query_utils.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ export function offsetLine(rings: Array<Array<Point>>, offset: number) {
100100
if (unitNormalAB.equals(zeroPoint) && unitNormalBC.equals(zeroPoint)) {
101101
// no change means final point will be a duplicate of the previous; can be excluded
102102
continue;
103-
} else {
104-
// unit bisector direction
105-
const bisectorDir = unitNormalAB._add(unitNormalBC)._unit();
106-
const cosHalfAngle = bisectorDir.x * unitNormalBC.x + bisectorDir.y * unitNormalBC.y;
107-
if (cosHalfAngle !== 0) {
108-
bisectorDir._mult(1 / cosHalfAngle);
109-
}
110-
newRing.push(bisectorDir._mult(offset)._add(point));
111103
}
104+
// unit bisector direction
105+
const bisectorDir = unitNormalAB._add(unitNormalBC)._unit();
106+
const cosHalfAngle = bisectorDir.x * unitNormalBC.x + bisectorDir.y * unitNormalBC.y;
107+
if (cosHalfAngle !== 0) {
108+
bisectorDir._mult(1 / cosHalfAngle);
109+
}
110+
newRing.push(bisectorDir._mult(offset)._add(point));
112111
}
113112
newRings.push(newRing);
114113
}

0 commit comments

Comments
 (0)