From e4c67b165bd2e642a96cda39490801a6a0df1d63 Mon Sep 17 00:00:00 2001 From: igurielidze Date: Mon, 30 Mar 2026 15:38:37 +0400 Subject: [PATCH] =?UTF-8?q?Fix=20EPC=20end=20box=20collision=20and=20bound?= =?UTF-8?q?s=20to=20match=2090=C2=B0=20rotation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rotate the direction vector -90° for the right box in collision detection and bounds calculation to match the perpendicular rendering orientation. Co-Authored-By: Claude Opus 4.6 (1M context) --- svelte-app/src/lib/canvas/collision.ts | 3 ++- svelte-app/src/lib/canvas/interactions.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/svelte-app/src/lib/canvas/collision.ts b/svelte-app/src/lib/canvas/collision.ts index fdede1e..76809fa 100644 --- a/svelte-app/src/lib/canvas/collision.ts +++ b/svelte-app/src/lib/canvas/collision.ts @@ -401,9 +401,10 @@ function getEpcCollisionQuads( // Right box quad const last = waypoints[waypoints.length - 1]; const prev = waypoints[waypoints.length - 2]; + const rbDx = last.x - prev.x, rbDy = last.y - prev.y; const rbQ = boxQuad( ox + last.x, oy + last.y, - last.x - prev.x, last.y - prev.y, + rbDy, -rbDx, // rotated -90° to match perpendicular end box EPC_CONFIG.rightBox.w, EPC_CONFIG.rightBox.h, 'right' ); diff --git a/svelte-app/src/lib/canvas/interactions.ts b/svelte-app/src/lib/canvas/interactions.ts index 01dcb22..9d5ab85 100644 --- a/svelte-app/src/lib/canvas/interactions.ts +++ b/svelte-app/src/lib/canvas/interactions.ts @@ -360,8 +360,8 @@ function recalcEpcBounds(sym: typeof layout.symbols[0]) { // Right box corners (oriented along last segment) const last = wps[wps.length - 1]; const prev = wps[wps.length - 2]; - const rbDir = { x: last.x - prev.x, y: last.y - prev.y }; - const rbCorners = orientedBoxCorners(last.x, last.y, rbDir.x, rbDir.y, EPC_CONFIG.rightBox.w, EPC_CONFIG.rightBox.h, 'right'); + const rbDx = last.x - prev.x, rbDy = last.y - prev.y; + const rbCorners = orientedBoxCorners(last.x, last.y, rbDy, -rbDx, EPC_CONFIG.rightBox.w, EPC_CONFIG.rightBox.h, 'right'); for (const [bx, by] of rbCorners) { minX = Math.min(minX, bx); minY = Math.min(minY, by); maxX = Math.max(maxX, bx); maxY = Math.max(maxY, by);