Public
Edited
Jun 16, 2023
19 stars
Insert cell
Insert cell
Insert cell
Insert cell
projection = d3
.geoMollweide()
.reflectX(true)
.fitExtent([[10, 10], [width - 10, height - 10]], { type: "Sphere" })
Insert cell
Insert cell
equatorial = [0, 0, 0]
Insert cell
ecliptic = [0, 0, -(23 + 26 / 60)]
Insert cell
// https://www.astro.rug.nl/software/kapteyn/celestialbackground.html
J2000 = [
[-0.054876, -0.873437, -0.483835],
[0.494109, -0.444830, 0.746982],
[-0.867666, -0.198076, 0.455984]
]
Insert cell
// https://www.astro.rug.nl/software/kapteyn-beta/celestialbackground.html
galactic2supergalactic = [
[-0.7357425748044, 0.6772612964139, -6.085819597056e-17],
[-0.07455377836523, -0.08099147130698, 0.9939225903998],
[0.6731453021092, 0.731271165817, 0.1100812622248]
]
Insert cell
Insert cell
// Euler angles bringing the Galaxy on the horizon y = 0
galactic = attitude()
.matrix(J2000)
.inverse()
.angles()
Insert cell
// Euler angles bringing the supergalactic plane on the horizon y = 0
supergalactic = attitude()
.matrix(galactic2supergalactic)
.inverse()
.compose(attitude(galactic))
.angles()
Insert cell
poles = ({
equatorial: [0, 90], // i.e. d3.geoRotation([0,0,0]).invert([0,90])
ecliptic: d3.geoRotation(ecliptic).invert([0, 90]),
galactic: d3.geoRotation(galactic).invert([0, 90]),
supergalactic: d3.geoRotation(supergalactic).invert([0, 90])
})
Insert cell
equator = pole =>
Object.assign(
d3
.geoCircle()
.radius(90)
.center(pole)(),
{ type: "MultiLineString" }
)
Insert cell
Insert cell
rotate = ({
equatorial,
ecliptic,
galactic,
supergalactic
}[alignement])
Insert cell
additionalRotate = [25, 0, 0] // just for fun
Insert cell
finalrotate = attitude(additionalRotate)
.compose(attitude(rotate))
.angles()
Insert cell
Insert cell
function flip(raw) {
if (!flipped) return raw;

const forward = (lambda, phi) => {
const p = raw(lambda, phi);
return p && (p[0] = -p[0]), p;
};

if (raw.invert) forward.invert = (x, y) => raw.invert(-x, y);

return forward;
}
Insert cell
antipode = point => [point[0] - 180, -point[1]]
Insert cell
height = width * 0.55
Insert cell
geometry = FileAttachment("milkyway.json").json()
Insert cell
d3 = require("d3@5", "d3-geo-projection@2.9")
Insert cell
attitude = require("attitude")
Insert cell
import { checkbox, select } from "@jashkenas/inputs"
Insert cell
import { drag } with { attitude } from "@fil/versor-dragging-with-attitude"
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