UNPKG

@chrisheninger/saxi

Version:

Drive the AxiDraw pen plotter

38 lines 979 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function vlen2(a) { return a.x * a.x + a.y * a.y; } exports.vlen2 = vlen2; function vlen(a) { return Math.sqrt(vlen2(a)); } exports.vlen = vlen; function vsub(a, b) { return { x: a.x - b.x, y: a.y - b.y }; } exports.vsub = vsub; function vmul(a, s) { return { x: a.x * s, y: a.y * s }; } exports.vmul = vmul; function vnorm(a) { return vmul(a, 1 / vlen(a)); } exports.vnorm = vnorm; function vadd(a, b) { return { x: a.x + b.x, y: a.y + b.y }; } exports.vadd = vadd; function vdot(a, b) { return a.x * b.x + a.y * b.y; } exports.vdot = vdot; function vrot(v, c, a) { if (a === 0) return v; let radians = (Math.PI / 180) * a, cos = Math.cos(radians), sin = Math.sin(radians), nx = cos * (v.x - c.x) - sin * (v.y - c.y) + c.x, ny = cos * (v.y - c.y) + sin * (v.x - c.x) + c.y; return { x: nx, y: ny }; } exports.vrot = vrot; //# sourceMappingURL=vec.js.map