UNPKG

saxi

Version:

Drive the AxiDraw pen plotter

38 lines 981 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.vlen2 = vlen2; exports.vlen = vlen; exports.vsub = vsub; exports.vmul = vmul; exports.vnorm = vnorm; exports.vadd = vadd; exports.vdot = vdot; exports.vrot = vrot; function vlen2(a) { return a.x * a.x + a.y * a.y; } function vlen(a) { return Math.sqrt(vlen2(a)); } function vsub(a, b) { return { x: a.x - b.x, y: a.y - b.y }; } function vmul(a, s) { return { x: a.x * s, y: a.y * s }; } function vnorm(a) { return vmul(a, 1 / vlen(a)); } function vadd(a, b) { return { x: a.x + b.x, y: a.y + b.y }; } function vdot(a, b) { return a.x * b.x + a.y * b.y; } function vrot(v, c, a) { if (a === 0) return v; const 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 }; } //# sourceMappingURL=vec.js.map