Kstars

ksearthshadow.cpp
1 /*
2  SPDX-FileCopyrightText: 2018 Valentin Boettcher <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #include "ksearthshadow.h"
7 #include "kssun.h"
8 #include "ksmoon.h"
9 
10 KSEarthShadow::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 {
47  updateCoords();
48  return true; //TODO: not nice!
49 }
50 
51 
52 void KSEarthShadow::updateCoords(const KSNumbers *, bool, const CachingDms *, const CachingDms *, bool )
53 {
54  updateCoords();
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 }
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:380
ECLIPSE_TYPE
The ECLIPSE_TYPE enum describes the quality of an eclipse.
Definition: ksearthshadow.h:45
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition: cachingdms.h:18
void updateCoords()
Update the RA/DEC of the shadow.
double rearth() const
Definition: ksplanetbase.h:139
void calculateShadowRadius()
Updates umbra and penumbra radius from the positions of the three bodies.
bool isInEclipse()
isInEclipse - a slim version of getEclipseType()
KSEarthShadow(const KSMoon *moon, const KSSun *sun, const KSPlanet *earth)
Provides necessary information about the Moon. A subclass of SkyObject that provides information need...
Definition: ksmoon.h:25
Provides necessary information about the Sun.
Definition: kssun.h:23
QString i18n(const char *text, const TYPE &arg...)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms & dec() const
Definition: skypoint.h:269
double illum() const
Definition: ksmoon.h:49
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...
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
Definition: skypoint.cpp:899
Provides necessary information about objects in the solar system.
Definition: ksplanet.h:32
void set(const dms &r, const dms &d)
Sets RA, Dec and RA0, Dec0 according to arguments.
Definition: skypoint.cpp:63
double physicalSize() const
Definition: ksplanetbase.h:192
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
double angSize() const
Definition: ksplanetbase.h:184
const CachingDms & ra() const
Definition: skypoint.h:263
const double & Degrees() const
Definition: dms.h:141
void reduceToRange(enum dms::AngleRanges range)
Reduce this angle to the given range.
Definition: dms.cpp:438
bool shouldUpdate()
The earths shadow on the moon appears only at new moon so calculating it on other occasions is rather...
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
ECLIPSE_TYPE getEclipseType()
eclipse
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.