Files
skyview.astronomiemuseum.de/public/js/stars.js
T
2026-03-31 09:44:27 +02:00

350 lines
14 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* AstroTools – Echter Sternenhimmel mit Sternbildern
Sternwarte Sonneberg · 50°22′N · 11°11′O
──────────────────────────────────────────────── */
(function () {
/* ── Standort ───────────────────────────────── */
const LAT = 50.377; // Grad Nord
const LON = 11.189; // Grad Ost
/* ── Sternkatalog ───────────────────────────────
[RA (Stunden), Dek (Grad), Magnitude]
─────────────────────────────────────────────── */
const CAT = [
// Orion
[ 5.919, 7.407, 0.42], // 0 Betelgeuse
[ 5.242, -8.202, 0.12], // 1 Rigel
[ 5.419, 6.350, 1.64], // 2 Bellatrix
[ 5.533, -0.299, 2.23], // 3 Mintaka
[ 5.603, -1.202, 1.69], // 4 Alnilam
[ 5.679, -1.943, 1.77], // 5 Alnitak
[ 5.796, -9.670, 2.06], // 6 Saiph
// Ursa Major (Großer Wagen)
[11.062, 61.751, 1.79], // 7 Dubhe
[11.031, 56.383, 2.37], // 8 Merak
[11.897, 53.695, 2.44], // 9 Phecda
[12.257, 57.033, 3.31], // 10 Megrez
[12.900, 55.960, 1.76], // 11 Alioth
[13.399, 54.925, 2.23], // 12 Mizar
[13.792, 49.313, 1.85], // 13 Alkaid
// Ursa Minor (Kleiner Wagen)
[ 2.530, 89.264, 1.97], // 14 Polaris
[14.845, 74.156, 2.08], // 15 Kochab
[15.345, 71.834, 3.05], // 16 Pherkad
// Cassiopeia (W)
[ 0.153, 59.150, 2.27], // 17 Caph
[ 0.675, 56.537, 2.24], // 18 Schedar
[ 0.945, 60.717, 2.15], // 19 Cih (γ Cas)
[ 1.430, 60.235, 2.68], // 20 Ruchbah
[ 1.907, 63.670, 3.38], // 21 Segin
// Gemini (Zwillinge)
[ 7.755, 28.026, 1.14], // 22 Pollux
[ 7.577, 31.888, 1.57], // 23 Castor
[ 6.629, 16.399, 1.93], // 24 Alhena
[ 7.335, 21.982, 3.53], // 25 Wasat
[ 6.882, 25.131, 2.98], // 26 Mebsuda
[ 6.379, 22.514, 3.28], // 27 Propus
// Taurus (Stier)
[ 4.599, 16.509, 0.85], // 28 Aldebaran
[ 5.438, 28.608, 1.65], // 29 Elnath
[ 3.791, 24.105, 2.85], // 30 Alcyone (Pleiaden)
[ 4.477, 19.181, 3.53], // 31 Ain
// Auriga (Fuhrmann)
[ 5.278, 45.998, 0.08], // 32 Capella
[ 5.992, 44.947, 1.90], // 33 Menkalinan
[ 5.995, 37.213, 2.65], // 34 Mahasim
// Leo (Löwe)
[10.140, 11.967, 1.35], // 35 Regulus
[11.818, 14.572, 2.14], // 36 Denebola
[10.333, 19.842, 2.01], // 37 Algieba
[11.235, 20.524, 2.56], // 38 Zosma
[10.897, 25.000, 3.44], // 39 Adhafera
[10.122, 23.774, 3.52], // 40 Rasalas
// Boötes (Bärenhüter)
[14.261, 19.182, -0.05], // 41 Arcturus
[14.750, 27.074, 2.37], // 42 Izar
[13.911, 18.398, 2.68], // 43 Muphrid
[14.535, 38.308, 3.04], // 44 Seginus
[15.032, 40.390, 3.49], // 45 Nekkar
// Cygnus (Schwan / Nordkreuz)
[20.691, 45.280, 1.25], // 46 Deneb
[20.370, 40.257, 2.23], // 47 Sadr
[20.770, 33.971, 2.48], // 48 Gienah (ε Cyg)
[19.512, 27.960, 3.08], // 49 Albireo
[19.749, 45.131, 2.87], // 50 δ Cyg
// Lyra (Leier)
[18.616, 38.784, 0.03], // 51 Vega
[18.835, 33.363, 3.52], // 52 Sheliak
[18.982, 32.690, 3.24], // 53 Sulafat
// Aquila (Adler)
[19.846, 8.868, 0.77], // 54 Altair
[19.771, 10.613, 2.72], // 55 Tarazed
[19.922, 6.407, 3.71], // 56 Alshain
// Scorpius (Skorpion)
[16.490,-26.432, 0.96], // 57 Antares
[17.560,-37.104, 1.62], // 58 Shaula
[17.622,-42.998, 1.86], // 59 Sargas
[16.006,-22.622, 2.29], // 60 Dschubba
[15.931,-19.805, 2.62], // 61 Graffias
[17.531,-37.298, 2.69], // 62 Lesath
// Sagittarius (Schütze / Teekanne)
[18.403,-34.385, 1.85], // 63 Kaus Australis
[18.921,-26.297, 2.02], // 64 Nunki
[18.350,-29.828, 2.70], // 65 Kaus Media
[18.345,-25.422, 2.81], // 66 Kaus Borealis
[18.466,-25.422, 2.89], // 67 Ascella
// Pegasus (Geflügeltes Pferd)
[23.079, 15.205, 2.49], // 68 Markab
[23.063, 28.083, 2.42], // 69 Scheat
[ 0.221, 15.184, 2.83], // 70 Algenib
[21.736, 9.875, 2.38], // 71 Enif
[22.691, 10.832, 2.83], // 72 Homam
// Andromeda
[ 0.140, 29.091, 2.07], // 73 Alpheratz (auch Pegasus-Ecke)
[ 1.162, 35.620, 2.07], // 74 Mirach
[ 2.065, 42.330, 2.10], // 75 Almach
// Perseus
[ 3.405, 49.861, 1.79], // 76 Mirfak
[ 3.136, 40.957, 2.12], // 77 Algol
[ 3.902, 31.884, 2.85], // 78 Atik
// Aries (Widder)
[ 2.120, 23.462, 2.01], // 79 Hamal
[ 1.911, 20.808, 2.64], // 80 Sheratan
// Virgo (Jungfrau)
[13.420,-11.161, 0.97], // 81 Spica
[12.694, -1.449, 2.74], // 82 Porrima
[13.036, 10.959, 2.83], // 83 Vindemiatrix
// Canis Major (Großer Hund)
[ 6.753,-16.716, -1.46], // 84 Sirius
[ 6.977,-28.972, 1.50], // 85 Adhara
[ 7.140,-26.393, 1.84], // 86 Wezen
[ 6.378,-17.956, 1.98], // 87 Mirzam
// Canis Minor (Kleiner Hund)
[ 7.655, 5.225, 0.38], // 88 Procyon
[ 7.453, 8.289, 2.90], // 89 Gomeisa
// Draco (Drache)
[17.943, 51.489, 2.23], // 90 Eltanin
[17.507, 52.301, 2.79], // 91 Rastaban
[16.400, 61.514, 3.29], // 92 Altais
// Corona Borealis (Nördliche Krone)
[15.578, 26.715, 2.21], // 93 Alphecca
[15.464, 29.106, 3.66], // 94 Nusakan
[15.700, 26.296, 3.84], // 95 γ CrB
// Hercules (Herkules)
[16.504, 21.490, 2.77], // 96 Kornephoros
[16.688, 31.602, 2.81], // 97 Zeta Her
[17.258, 36.809, 3.16], // 98 Pi Her
[16.714, 38.922, 3.48], // 99 Eta Her
// Ophiuchus / Schlangenträger
[17.582, 12.560, 2.08], // 100 Rasalhague
[16.619, 9.375, 2.43], // 101 Sabik
];
/* ── Sternbild-Linien ──────────────────────────
Paare [von, bis] als Indizes in CAT
─────────────────────────────────────────────── */
const LINES = [
// Orion
[0, 2], [2, 3], [3, 4], [4, 5], [5, 0], // Körper (Schultern→Gürtel→zurück)
[3, 1], [5, 6], // Beine (Mintaka→Rigel, Alnitak→Saiph)
// Ursa Major – Großer Wagen
[7, 8], [8, 9], [9, 10], [10, 7], // Kastenrahmen
[10, 11], [11, 12], [12, 13], // Deichsel
// Ursa Minor – Kleiner Wagen
[14, 15], [15, 16],
// Cassiopeia – W
[17, 18], [18, 19], [19, 20], [20, 21],
// Gemini – Zwillinge
[22, 23], // Pollux-Castor (Köpfe)
[22, 25], [25, 24], // Pollux-Körper
[23, 26], [26, 27], // Castor-Körper
// Taurus – Stier
[28, 31], [28, 29], // Hyaden V + Horn Elnath
[30, 28], // Pleiaden → Aldebaran
// Auriga – Fuhrmann (Pentagon)
[32, 33], [33, 34], [34, 29], [29, 32],
// Leo – Löwe (Sichel + Körper)
[35, 37], [37, 39], [39, 40], [40, 35], // Sichel / Kopf
[37, 38], [38, 36], // Körper → Denebola
// Boötes – Bärenhüter
[41, 43], [41, 42], [42, 44], [44, 45],
// Cygnus – Schwan / Nordsternkreuz
[46, 47], [47, 49], // Längsbalken Deneb→Albireo
[48, 47], [47, 50], // Querbalken
// Lyra – Leier
[51, 52], [52, 53], [53, 51],
// Aquila – Adler
[55, 54], [54, 56],
// Scorpius – Skorpion
[61, 60], [60, 57], // Kopf → Antares
[57, 65], [65, 63], [63, 62], [62, 58], // Schwanz
// Sagittarius – Teekanne
[66, 65], [65, 63], [63, 67], [67, 64],
[64, 66],
// Pegasus – Großes Quadrat
[68, 69], [69, 73], [73, 70], [70, 68],
[71, 72], [72, 68], // Enif (Pferdekopf)
// Andromeda
[73, 74], [74, 75],
// Perseus
[76, 77], [76, 78],
// Aries – Widder
[79, 80],
// Virgo – Jungfrau
[81, 82], [82, 83],
// Canis Major
[84, 87], [84, 85], [85, 86],
// Canis Minor
[88, 89],
// Draco – Drache (Kopf)
[90, 91], [91, 92],
// Corona Borealis – Nördliche Krone
[94, 93], [93, 95],
// Hercules – Schlüsselstein
[96, 97], [97, 99], [99, 98], [98, 96],
// Ophiuchus
[100, 101],
];
/* ── Hintergrund: zufällige Sterne (RA/Dek kugelverteilt) ── */
const BG = Array.from({ length: 350 }, () => ({
ra: Math.random() * 24,
dec: Math.asin(Math.random() * 2 - 1) * 180 / Math.PI,
mag: 3.8 + Math.random() * 2.2,
ph: Math.random() * Math.PI * 2,
tw: 2500 + Math.random() * 5000,
}));
/* ── Canvas ─────────────────────────────────── */
const canvas = document.getElementById('stars');
if (!canvas) return;
const ctx = canvas.getContext('2d');
let W, H;
function resize() {
W = canvas.width = window.innerWidth;
H = canvas.height = window.innerHeight;
}
/* ── Lokale Sternzeit (LST) ─────────────────── */
function getLST(d) {
const jd = d.getTime() / 86400000 + 2440587.5;
const T = (jd - 2451545.0) / 36525;
let gmst = (6.697374558 + 2400.0513369 * T + 0.0000258622 * T * T) % 24;
if (gmst < 0) gmst += 24;
const ut = d.getUTCHours() + d.getUTCMinutes() / 60 + d.getUTCSeconds() / 3600;
return ((gmst + ut * 1.00273790935 + LON / 15) % 24 + 24) % 24;
}
/* ── Höhe über Horizont (Grad) ──────────────── */
function altitude(ra, dec, lst) {
const H = (lst - ra) * 15 * Math.PI / 180;
const dRad = dec * Math.PI / 180;
const lRad = LAT * Math.PI / 180;
const sinA = Math.sin(dRad) * Math.sin(lRad) + Math.cos(dRad) * Math.cos(lRad) * Math.cos(H);
return Math.asin(Math.max(-1, Math.min(1, sinA))) * 180 / Math.PI;
}
/* ── Projektion: äquatorial flach ──────────────
LST steht im Bildzentrum (Meridian = Mitte)
Dek 25° im vertikalen Zentrum
12 Stunden RA sichtbar (halber Himmel)
─────────────────────────────────────────────── */
const REF_DEC = 25;
function project(ra, dec, lst) {
let dRA = lst - ra;
if (dRA > 12) dRA -= 24;
if (dRA < -12) dRA += 24;
const pph = W / 12; // Pixel pro Stunde RA
const ppd = pph / 15; // Pixel pro Grad Dek
return {
x: W / 2 + dRA * pph,
y: H / 2 - (dec - REF_DEC) * ppd,
};
}
/* ── Sternradius aus Magnitude ──────────────── */
function magR(m) {
return Math.max(0.4, 3.5 - m * 0.65);
}
/* ── Zeichnen ───────────────────────────────── */
function draw(time) {
ctx.clearRect(0, 0, W, H);
const lst = getLST(new Date());
const pad = 30;
/* 1 · Hintergrund-Sterne */
for (const s of BG) {
const alt = altitude(s.ra, s.dec, lst);
if (alt < -8) continue;
const p = project(s.ra, s.dec, lst);
if (p.x < -pad || p.x > W + pad || p.y < -pad || p.y > H + pad) continue;
const twinkle = 0.35 + 0.55 * (0.5 + 0.5 * Math.sin(time / s.tw + s.ph));
const horizFade = alt < 0 ? Math.max(0, 1 + alt / 8) : 1;
ctx.beginPath();
ctx.arc(p.x, p.y, magR(s.mag), 0, Math.PI * 2);
ctx.fillStyle = `rgba(210,225,255,${(twinkle * horizFade * 0.4).toFixed(3)})`;
ctx.fill();
}
/* 2 · Sternbild-Linien */
ctx.lineWidth = 0.7;
for (const [a, b] of LINES) {
const [raA, decA] = CAT[a];
const [raB, decB] = CAT[b];
const altA = altitude(raA, decA, lst);
const altB = altitude(raB, decB, lst);
if (altA < -8 && altB < -8) continue;
const pa = project(raA, decA, lst);
const pb = project(raB, decB, lst);
if (Math.abs(pa.x - pb.x) > W * 0.55) continue; // RA-Wrap überspringen
const fade = Math.max(0, Math.min(1, (Math.max(altA, altB) + 5) / 15));
ctx.strokeStyle = `rgba(200,168,75,${(fade * 0.14).toFixed(3)})`;
ctx.beginPath();
ctx.moveTo(pa.x, pa.y);
ctx.lineTo(pb.x, pb.y);
ctx.stroke();
}
/* 3 · Katalog-Sterne (Hellsterne) */
for (const [ra, dec, mag] of CAT) {
const alt = altitude(ra, dec, lst);
if (alt < -6) continue;
const p = project(ra, dec, lst);
if (p.x < -pad || p.x > W + pad || p.y < -pad || p.y > H + pad) continue;
const horizFade = alt < 5 ? Math.max(0.08, (alt + 6) / 11) : 1;
const twinkle = 0.8 + 0.2 * Math.sin(time / 1600 + ra * 0.7);
const alpha = Math.min(1, horizFade * twinkle);
const r = magR(mag);
// Leuchthof für Sterne heller als mag 2
if (mag < 2.0) {
const glowR = r * (mag < 0.5 ? 6 : mag < 1.0 ? 5 : 4);
const glow = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, glowR);
glow.addColorStop(0, `rgba(220,235,255,${(alpha * 0.28).toFixed(3)})`);
glow.addColorStop(1, 'rgba(220,235,255,0)');
ctx.beginPath();
ctx.arc(p.x, p.y, glowR, 0, Math.PI * 2);
ctx.fillStyle = glow;
ctx.fill();
}
ctx.beginPath();
ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
ctx.fillStyle = `rgba(235,242,255,${alpha.toFixed(3)})`;
ctx.fill();
}
requestAnimationFrame(draw);
}
window.addEventListener('resize', resize);
resize();
requestAnimationFrame(draw);
})();