@rickosborne/hexgrid
Version:
Rick Osborne's collection of hexagonal grid-related code.
22 lines (21 loc) • 682 B
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
import { cubeAdd } from "./cube-add.mjs";
import { cubeSubtract } from "./cube-subtract.mjs";
import { CUBE, CW_60 } from "./hex-system.mjs";
const cubeRotate = /* @__PURE__ */ __name((center, outer, rotation) => {
const steps = rotation / CW_60;
const vector = cubeSubtract(outer, center);
let { q, r, s } = vector;
for (let i = 0; i < steps; i++) {
const t = q;
q = -r;
r = -s;
s = -t;
}
return cubeAdd(center, { q, r, s, system: CUBE });
}, "cubeRotate");
export {
cubeRotate
};
//# sourceMappingURL=cube-rotate.mjs.map