Lunar Craters
Astronomy
Mapping
Code
= {
chart const width = fullWidth,
= fullHeight;
height
const window = d3.create("svg")
.attr("width", "100%")
.attr("height", "100%")
.attr("viewBox", `0 0 ${fullWidth} ${fullHeight}`)
.attr("preserveAspectRatio", "xMidYMid meet");
const svg = window.append("g")
.attr("class", "moon");
const graticule = d3.geoGraticule();
const projection = d3.geoOrthographic()
.rotate([0, 0])
.translate([width / 2, height / 2])
.scale(200)
.clipAngle(90);
const path = d3.geoPath()
.projection(projection);
const circle = d3.geoCircle()
.center(d => [d.lon, d.lat])
.radius(d => d.d / 2 / 1737 * 180 / Math.PI)
.precision(20);
.append("rect")
svg.attr("width", width)
.attr("height", height)
.attr("fill", "#000000");
.append("path")
svg.datum(graticule.outline())
.attr("fill", "#bdbdbd")
.attr("d", path);
.append("path")
svg.datum(graticule())
.attr("class", "geo-path")
.attr("fill", "none")
.attr("stroke", "#252525")
.attr("stroke-width", 0.5)
.attr("stroke-opacity", 0.2)
.attr("d", path);
.selectAll(".crater")
svg.data(craters.map(d => circle(d)))
.join("path")
.attr("class", "crater geo-path")
.attr("fill", "#969696")
.attr("stroke", "#737373")
.attr("fill-opacity", 0.5)
.attr("d", path);
function render() {
.selectAll(".geo-path")
d3.attr("d", path);
}
function tick() {
const origin = projection.rotate();
0] += 0.1;
origin[.rotate(origin);
projectionrender();
}
function start() {
return d3.interval(tick, 20);
}
let timer = start();
let v0, r0, q0, v1, r1, q1;
const drag = d3.drag();
.on("start", function(event) {
drag.stop();
timer= versor.cartesian(
v0 .invert(d3.pointer(event, this)));
projection= projection.rotate();
r0 = versor(r0);
q0 ;
})
.on("drag", function(event) {
drag= versor.cartesian(
v1 .rotate(r0).invert(d3.pointer(event, this)));
projection= versor.multiply(q0, versor.delta(v0, v1));
q1 = versor.rotation(q1);
r1 .rotate(r1);
projectionrender();
;
})
.on("end", function() {
drag= start();
timer ;
})
.call(drag);
svg
.then(() => {
invalidation.stop();
timer;
})
return window.node();
}
Shown on this moon globe are all large lunar craters (with diameters greater than 50 km).