Kstars

ksconjunct.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Akarsh Simha <kstar@bas.org.in>
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
21dms 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
32void 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
49double 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}
Implements algorithms to find close approaches of two objects on the sky.
void solverMadeProgress(int progress)
solverMadeProgress
dms findSkyPointDistance(SkyPoint *obj1, SkyPoint *obj2)
findSkyPointDistance
GeoLocation * getGeoLocation()
getGeoLocation
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition cachingdms.h:19
KSConjunct()
Constructor.
double findInitialStep(long double startJD, long double stopJD) override
findStep
void updatePositions(long double jd) override
updatePositions
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.
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.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
virtual void setD(const double &x)
Sets floating-point value of angle, in degrees.
Definition dms.h:179
const double & Degrees() const
Definition dms.h:141
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.