Published
Edited
Jan 2, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
box = {
const svgstars = [];
for (const {sra0, sdec0, mag, xno} of stars.filter(d => d.mag < 5)) {
const r = 1.5*radius(mag);
const [z,x,y] = v.cartesian3([],[100,sdec0,sra0]);
const fill = catalog[xno-1].constellation === highlight ? 'white' : 'gray';
svgstars.push(translate([x,y,z], cull(svgt`<circle cx=${0} cy=${0} ${{r, fill}}/>`)));
}
const svgplanets = [];
for (const {name, raw: { position, magnitude } } of planets) {
const { dRA, dDec } = position.apparent
const r = 1.5*radius(magnitude);
const [z,x,y] = v.cartesian3([],[100,dDec,dRA]);
const fill = 'white';
const planet = svgt`
<circle cx=${0} cy=${0} ${{r, fill}}/>
<text x=${0} y=${0} ${{fill,'dominant-baseline':'hanging'}}>&nbsp;${name}</text>`
svgplanets.push(translate([x,y,z], cull(planet)));
}
//const view = camera.matrixWorldInverse.elements;
//const project = camera.projectionMatrix.elements;
const box = svgtBox(transform(camMatrix,g(...svgstars,...svgplanets)), 0.6*width,0.6*width);
box.style.backgroundColor = '#081f2b';
stable.replaceChildren(box);
}
Insert cell
Insert cell
camera = {
const camera = new T.PerspectiveCamera(80, 1, 1, 1000);
camera.position.set(0, 0, 100);
camera.updateProjectionMatrix();
// hackety hack
const _lookAt = camera.lookAt.bind(camera);
camera.lookAt = (target) => {
_lookAt(target);
mutable camMatrix = m.concat([],camera.projectionMatrix.elements,camera.matrixWorldInverse.elements);
};
return camera;
}
Insert cell
Insert cell
Insert cell
ephemeris = require('https://bundle.run/ephemeris@2.0.0')
Insert cell
herravad = [56.0881, 13.2322, 0]
Insert cell
getAllPlanets = (t) => Object.values(ephemeris.getAllPlanets(t, ...herravad).observed)
.filter(d => d.raw.magnitude)
.map(d => ({...d, raw: {...d.raw}})) // weird: .raw seems to get reused?
Insert cell
times = d3.timeDay.range(new Date('1576-01-01'), new Date('1576-12-31'))
Insert cell
allPlanets = new Map(times.map((t) => [t, getAllPlanets(t)]))
Insert cell
planets = allPlanets.get(t)
Insert cell
import { stars, catalog } from '@visnup/yale-bright-star-catalog'
Insert cell
radius = d3.scaleLinear([6, -1], [0, 1])
Insert cell
Insert cell
Insert cell
import { Scrubber } from '@mbostock/scrubber'
Insert cell
import { nominative } from '@mbostock/star-map'
Insert cell
d3 = require('d3-scale@3', 'd3-time@2')
Insert cell
Insert cell
import { svgt, translate, g, transform, svgtBox, rotateY, cull } from '@sanderevers/svg-transformations'
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