From f8da5b63253620fb90c12274751164c2428d4c55 Mon Sep 17 00:00:00 2001 From: Joel Matejka Date: Tue, 13 Aug 2019 17:44:49 +0200 Subject: [PATCH] Workaround for #41 --- js/Cam.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/Cam.js b/js/Cam.js index fbd5ee2..a2b6234 100644 --- a/js/Cam.js +++ b/js/Cam.js @@ -406,7 +406,9 @@ jscut.priv.cam = jscut.priv.cam || {}; var currentZ = safeZ; var finishedZ = topZ; - while (finishedZ > botZ) { + // Hide floating-point arithmetic imprecision and work with g-code precision + // to avoid possible duplication of the last pass + while (Number(finishedZ.toFixed(decimal)) > Number(botZ.toFixed(decimal))) { var nextZ = Math.max(finishedZ - passDepth, botZ); if (currentZ < safeZ && (!path.safeToClose || tabGeometry.length > 0)) { gcode += retractGcode;