From 3ca46a065f8521c6456b9e048aef247c366786f4 Mon Sep 17 00:00:00 2001 From: Ouyang Leyan Date: Tue, 15 Oct 2024 23:42:48 +0200 Subject: [PATCH] more precise angle computation --- src/stylefunction.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stylefunction.js b/src/stylefunction.js index 1787b361..6fccae77 100644 --- a/src/stylefunction.js +++ b/src/stylefunction.js @@ -835,11 +835,11 @@ export function stylefunction( const minY = Math.min(y1, y2); const maxX = Math.max(x1, x2); const maxY = Math.max(y1, y2); + 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 + && xM<=maxX && xM>=minX ) { placementAngle = Math.atan2(y1 - y2, x2 - x1); break;