fix rounding errors

#38
This commit is contained in:
Casper Lamboo 2018-03-06 17:16:33 +01:00
parent 8bb97527f4
commit b29198edd4

View File

@ -10,7 +10,6 @@ import optimizePaths from './optimizePaths.js';
import shapesToSlices from './shapesToSlices.js'; import shapesToSlices from './shapesToSlices.js';
import slicesToGCode from './slicesToGCode.js'; import slicesToGCode from './slicesToGCode.js';
import applyPrecision from './applyPrecision.js'; import applyPrecision from './applyPrecision.js';
import { PRECISION } from '../constants.js';
import { hslToRgb } from './helpers/color.js'; import { hslToRgb } from './helpers/color.js';
// // import removePrecision from './removePrecision.js'; // // import removePrecision from './removePrecision.js';
@ -70,7 +69,7 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev
return gcode; return gcode;
} }
const PRECISION_INVERSE = 1 / PRECISION; const PRECISION_INVERSE = 1000;
function toFixedTrimmed(value) { function toFixedTrimmed(value) {
return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString(); return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString();
} }