Published
Edited
Jul 29, 2020
3 forks
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getHexGridCircles(hexGrids[0], scale)
Insert cell
function getHexGridCircles(vertices, scale) {
var baseString = vertices.map(vertex => {
const x = scale * vertex[0];
const y = scale * vertex[1];
const ring = vertex[2];
const sextant = vertex[3];
let circle = getPointsAroundACircle(
getPointObject([x, y]),
scale / Math.sqrt(3),
6,
Math.PI / 6
);
circle.push(circle[0]);
// little trick to deduplicate edges in the lattice
if (ring % 2 === 1) {
circle = circle.filter(
(c, i) => i === (sextant + 1) % 6 || i === (sextant + 2) % 6
);
}
return circle;
});
return baseString;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more