Kstars

ksconjunct.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "ksconjunct.h"
8 
9 #include "ksnumbers.h"
10 #include "kstarsdata.h"
11 #include "skyobjects/skyobject.h"
12 #include "skyobjects/ksplanetbase.h"
13 
14 #include <cmath>
15 
17 {
18  connect(this, &ApproachSolver::solverMadeProgress, this, &KSConjunct::madeProgress);
19 }
20 
21 dms KSConjunct::findDistance()
22 {
23  dms dist = findSkyPointDistance(m_object1.get(), m_object2.get());
24  if (m_opposition)
25  {
26  dist.setD(180 - dist.Degrees());
27  }
28 
29  return dist;
30 }
31 
32 void KSConjunct::updatePositions(long double jd)
33 {
34  KStarsDateTime t(jd);
35  KSNumbers num(jd);
36 
37  m_Earth.findPosition(&num);
38  CachingDms LST(getGeoLocation()->GSTtoLST(t.gst()));
39 
40  KSPlanetBase *p = dynamic_cast<KSPlanetBase*>(m_object1.get());
41  if (p)
42  p->findPosition(&num, getGeoLocation()->lat(), &LST, &m_Earth);
43  else
44  m_object1->updateCoordsNow(&num);
45 
46  m_object2->findPosition(&num, getGeoLocation()->lat(), &LST, &m_Earth);
47 }
48 
49 double KSConjunct::findInitialStep(long double startJD, long double stopJD)
50 {
51 
52  double step0 =
53  double(stopJD - startJD) / 4.0; // I'm an idiot for having done this without having the lines that follow -- asimha
54 
55  // TODO: Work out a solid footing on which one can decide step0. -- asimha
56  if (step0 > 24.8 * 365.25) // Sample pluto's orbit (248.09 years) at least 10 times.
57  step0 = 24.8 * 365.25;
58 
59  // FIXME: This can be done better, but for now, I'm doing it the dumb way -- asimha
60  if (m_object1->name() == i18n("Neptune") || m_object2->name() == i18n("Neptune") || m_object1->name() == i18n("Uranus") ||
61  m_object2->name() == i18n("Uranus"))
62  if (step0 > 3652.5)
63  step0 = 3652.5;
64  if (m_object1->name() == i18n("Jupiter") || m_object2->name() == i18n("Jupiter") || m_object1->name() == i18n("Saturn") ||
65  m_object2->name() == i18n("Saturn"))
66  if (step0 > 365.25)
67  step0 = 365;
68  if (m_object1->name() == i18n("Mars") || m_object2->name() == i18n("Mars"))
69  if (step0 > 10.0)
70  step0 = 10.0;
71  if (m_object1->name() == i18n("Venus") || m_object1->name() == i18n("Mercury") || m_object2->name() == i18n("Mercury") ||
72  m_object2->name() == i18n("Venus"))
73  if (step0 > 5.0)
74  step0 = 5.0;
75  if (m_object1->name() == i18n("Moon") || m_object2->name() == i18n("Moon"))
76  if (step0 > 0.25)
77  step0 = 0.25;
78 
79  return step0;
80 }
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
GeoLocation * getGeoLocation()
getGeoLocation
virtual void setD(const double &x)
Sets floating-point value of angle, in degrees.
Definition: dms.h:179
void solverMadeProgress(int progress)
solverMadeProgress
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition: cachingdms.h:18
void findPosition(const KSNumbers *num, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, const KSPlanetBase *Earth=nullptr)
Find position, including correction for Figure-of-the-Earth.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString i18n(const char *text, const TYPE &arg...)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms * lat() const
Definition: geolocation.h:70
Implements algorithms to find close approaches of two objects on the sky. A class that implements a m...
void updatePositions(long double jd) override
updatePositions
Definition: ksconjunct.cpp:32
double findInitialStep(long double startJD, long double stopJD) override
findStep
Definition: ksconjunct.cpp:49
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
KSConjunct()
Constructor.
Definition: ksconjunct.cpp:16
const double & Degrees() const
Definition: dms.h:141
dms findSkyPointDistance(SkyPoint *obj1, SkyPoint *obj2)
findSkyPointDistance
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.