Skip to content

Commit

Permalink
Prevent division by zero in offsetLine
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoelewijn committed Mar 20, 2022
1 parent 31b2c8f commit 4d5905e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/style/query_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export function offsetLine(rings, offset) {
const extrude = aToB._add(bToC)._unit();

const cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;
extrude._mult(1 / cosHalfAngle);
if (cosHalfAngle !== 0) {
extrude._mult(1 / cosHalfAngle);
}

newRing.push(extrude._mult(offset)._add(b));
}
Expand Down

0 comments on commit 4d5905e

Please sign in to comment.