Komet in Sternnenhimmel gefixt

This commit is contained in:
2026-04-14 07:52:08 +02:00
parent eac408fc21
commit 742d8dc292
+9 -6
View File
@@ -1683,13 +1683,16 @@ function drawComets(date) {
comet._xy = pt;
comet._pos = pos;
// Schweifrichtung: vom Sonnenzentrum weg (Näherung über Sonnenazimut)
// Schweifrichtung: vom Sonnenzentrum weg (auch wenn Sonne unter dem Horizont)
let tailAngle = -Math.PI * 0.65;
if (sunCache && Number.isFinite(sunCache.az)) {
const sunPt = project(sunCache.alt, sunCache.az);
if (sunPt) {
tailAngle = Math.atan2(pt.y - sunPt.y, pt.x - sunPt.x);
}
if (sunCache && Number.isFinite(sunCache.az) && Number.isFinite(sunCache.alt)) {
// Virtuelle Sonnenposition berechnen – ohne Horizont-Prüfung,
// damit der Schweif auch bei Nacht korrekt von der Sonne weg zeigt
const sunRho = (90.0 - sunCache.alt) / 90.0;
const sunAzR = sunCache.az * Math.PI / 180.0;
const sunVX = cx - sunRho * R * Math.sin(sunAzR);
const sunVY = cy - sunRho * R * Math.cos(sunAzR);
tailAngle = Math.atan2(pt.y - sunVY, pt.x - sunVX);
}
// Schweifläng: sonnennah = lang, sonnenfern = kurz (20/rH AU, Bereich 6–55 px)
const tailLen = pos.rH > 0 ? Math.max(6, Math.min(55, 20 / pos.rH)) : 12;