diff --git a/src/sliceActions/helpers/GCode.js b/src/sliceActions/helpers/GCode.js index 4cc6bf5..0004843 100644 --- a/src/sliceActions/helpers/GCode.js +++ b/src/sliceActions/helpers/GCode.js @@ -1,4 +1,4 @@ -import { divide, distanceTo } from './VectorUtils.js'; +import { scale, distanceTo } from './VectorUtils.js'; import { PRECISION, VERSION } from '../../constants.js'; export const MOVE = 'G'; @@ -10,8 +10,6 @@ export const POSITION_X = 'X'; export const POSITION_Y = 'Y'; export const POSITION_Z = 'Z'; -const PRECISION_INVERSE = 1 / PRECISION; - export default class { constructor(layerHeight) { this._nozzleToFilamentRatio = 1; @@ -54,7 +52,7 @@ export default class { } moveTo(x, y, z, { speed }) { - const newNozzlePosition = divide({ x, y }, PRECISION_INVERSE); + const newNozzlePosition = scale({ x, y }, PRECISION); const lineLength = distanceTo(this._nozzlePosition, newNozzlePosition); this._duration += lineLength / speed; @@ -73,7 +71,7 @@ export default class { } lineTo(x, y, z, { speed, flowRate }) { - const newNozzlePosition = divide({ x, y }, PRECISION_INVERSE); + const newNozzlePosition = scale({ x, y }, PRECISION); const lineLength = distanceTo(this._nozzlePosition, newNozzlePosition); this._extruder += this._nozzleToFilamentRatio * lineLength * flowRate;