Kstars

ksearthshadow.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Valentin Boettcher <valentin@boettcher.cf>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#include "ksearthshadow.h"
7#include "kssun.h"
8#include "ksmoon.h"
9
10KSEarthShadow::KSEarthShadow(const KSMoon *moon, const KSSun *sun, const KSPlanet * earth)
11 : KSPlanetBase (i18n("Earth Shadow")), m_sun { sun }, m_moon { moon }, m_earth {earth}
12{
13}
14
16{
17 return (m_moon->illum() > 0.8);
18}
19
21{
22 double dist = angularDistanceTo(m_moon).Degrees() * 60;
23 return (dist - m_moon->angSize() / 2) <= m_penumbra_ang;
24}
25
27{
28 double half_a_moon = m_moon->angSize() / 2;
29 double dist = angularDistanceTo(m_moon).Degrees() * 60; // arcminutes
30 if (dist <= (m_penumbra_ang - half_a_moon))
31 {
32 if(dist <= (m_umbra_ang - half_a_moon))
33 return FULL_UMBRA;
34 else
35 return FULL_PENUMBRA;
36 }
37 else if ((dist - half_a_moon) <= m_penumbra_ang)
38 {
39 return PARTIAL;
40 }
41
42 return NONE;
43}
44
46{
48 return true; //TODO: not nice!
49}
50
51
52void KSEarthShadow::updateCoords(const KSNumbers *, bool, const CachingDms *, const CachingDms *, bool )
53{
55}
56
57//TODO: Abort if Null
59{
60 // flip the sun around to get the 'shadow coordinates'
61 dms t_ra(m_sun->ra().Degrees() + 180);
62 t_ra.reduceToRange(dms::ZERO_TO_2PI);
63 dms t_dec(-1 * (m_sun->dec().Degrees()));
64
65 set(t_ra, t_dec);
66 Rearth = m_moon->rearth();
67}
68
69
70//NOTE: This can easily be generalized to any three bodies.
72{
73 double d_sun = m_sun->rearth() * AU_KM;
74 double d_moon = m_moon->rearth() * AU_KM;
75 double r_sun = m_sun->physicalSize() / 2;
76 double r_earth = m_earth->physicalSize() / 2;
77
78 double umbraRad = 1.01 * r_earth + (r_earth - r_sun) / d_sun * d_moon;
79 double penumbraRad = 1.01 * r_earth + (r_sun + r_earth) / d_sun * d_moon;
80
81 m_umbra_ang = asin(umbraRad / d_moon) * 60. * 180. / dms::PI;
82 m_penumbra_ang = asin(penumbraRad / d_moon) * 60. * 180. / dms::PI;
83
84 return;
85}
void updateCoords()
Update the RA/DEC of the shadow.
bool findGeocentricPosition(const KSNumbers *, const KSPlanetBase *Earth=nullptr) override
find the object's current geocentric equatorial coordinates (RA and Dec) This function is pure virtua...
bool shouldUpdate()
The earths shadow on the moon appears only at new moon so calculating it on other occasions is rather...
ECLIPSE_TYPE getEclipseType()
eclipse
KSEarthShadow(const KSMoon *moon, const KSSun *sun, const KSPlanet *earth)
bool isInEclipse()
isInEclipse - a slim version of getEclipseType()
ECLIPSE_TYPE
The ECLIPSE_TYPE enum describes the quality of an eclipse.
void calculateShadowRadius()
Updates umbra and penumbra radius from the positions of the three bodies.
Provides necessary information about the Moon.
Definition ksmoon.h:26
double illum() const
Definition ksmoon.h:49
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
A subclass of TrailObject that provides additional information needed for most solar system objects.
double physicalSize() const
double angSize() const
double rearth() const
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Definition ksplanet.h:33
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition kssun.h:24
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
Definition skypoint.cpp:899
void set(const dms &r, const dms &d)
Sets RA, Dec and RA0, Dec0 according to arguments.
Definition skypoint.cpp:63
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
Definition dms.h:385
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.