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);