From 742d8dc292dcf92fcf51a558dc3be114aa49a3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 14 Apr 2026 07:52:08 +0200 Subject: [PATCH] Komet in Sternnenhimmel gefixt --- public/sternenhimmel.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/public/sternenhimmel.php b/public/sternenhimmel.php index 9db6cf0..461c478 100644 --- a/public/sternenhimmel.php +++ b/public/sternenhimmel.php @@ -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;