Skip to content

Commit

Permalink
more precise angle computation
Browse files Browse the repository at this point in the history
  • Loading branch information
leyan committed Oct 15, 2024
1 parent a4ff0cb commit 3ca46a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/stylefunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,11 @@ export function stylefunction(
const minY = Math.min(y1, y2);

Check failure on line 835 in src/stylefunction.js

View workflow job for this annotation

GitHub Actions / test

'minY' is assigned a value but never used
const maxX = Math.max(x1, x2);
const maxY = Math.max(y1, y2);

Check failure on line 837 in src/stylefunction.js

View workflow job for this annotation

GitHub Actions / test

'maxY' is assigned a value but never used
const xM = midpoint[0];
const yM = midpoint[1];
if (
midpoint[0] >= minX &&
midpoint[0] <= maxX &&
midpoint[1] >= minY &&
midpoint[1] <= maxY
Math.abs((y2-y1)*(xM-x1) - (x2-x1)*(yM-y1))<0.001 //midpoint is aligned with the segment

Check failure on line 841 in src/stylefunction.js

View workflow job for this annotation

GitHub Actions / test

Replace `(y2-y1)*(xM-x1)·-·(x2-x1)*(yM-y1))<0.001` with `⏎····························(y2·-·y1)·*·(xM·-·x1)·-·(x2·-·x1)·*·(yM·-·y1),⏎··························)·<·0.001·&&`
&& xM<=maxX && xM>=minX

Check failure on line 842 in src/stylefunction.js

View workflow job for this annotation

GitHub Actions / test

Replace `&&·xM<=maxX·&&·xM>=` with `xM·<=·maxX·&&⏎··························xM·>=·`
) {
placementAngle = Math.atan2(y1 - y2, x2 - x1);
break;
Expand Down

0 comments on commit 3ca46a0

Please sign in to comment.