UNPKG

@rickosborne/hexgrid

Version:

Rick Osborne's collection of hexagonal grid-related code.

45 lines (44 loc) 1.93 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var qrs_intersection_exports = {}; __export(qrs_intersection_exports, { qrsIntersection: () => qrsIntersection }); module.exports = __toCommonJS(qrs_intersection_exports); const qrsIntersection = /* @__PURE__ */ __name((buildFn, center1, radius1, center2, radius2 = radius1) => { const points = []; const qMin = Math.max(center1.q - radius1, center2.q - radius2); const qMax = Math.min(center1.q + radius1, center2.q + radius2); const rMin = Math.max(center1.r - radius1, center2.r - radius2); const rMax = Math.min(center1.r + radius1, center2.r + radius2); const s1 = -center1.q - center1.r; const s2 = -center2.q - center2.r; const sMin = Math.max(s1 - radius1, s2 - radius2); const sMax = Math.min(s1 + radius1, s2 + radius2); for (let q = qMin; q <= qMax; q++) { const ra = Math.max(rMin, -q - sMax); const rb = Math.min(rMax, -q - sMin); for (let r = ra; r <= rb; r++) { points.push(buildFn(q, r)); } } return points; }, "qrsIntersection"); //# sourceMappingURL=qrs-intersection.cjs.map