Kstars

skyline.cpp
1/*
2 SPDX-FileCopyrightText: 2006 Jason Harris <kstarss@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "skyline.h"
8
9#include "kstarsdata.h"
10#include "ksnumbers.h"
11
12#include <QDebug>
13
14SkyLine::~SkyLine()
15{
16 clear();
17}
18
20{
21 qDeleteAll(m_pList);
22 m_pList.clear();
23}
24
26{
27 m_pList.append(new SkyPoint(*p));
28}
29
31{
32 if (i < 0 || i >= m_pList.size())
33 {
34 qDebug() << Q_FUNC_INFO << "SkyLine index error: no such point: " << i;
35 return;
36 }
37 *m_pList[i] = *p;
38}
39
41{
42 if (i < 0 || i + 1 >= m_pList.size())
43 {
44 qDebug() << Q_FUNC_INFO << "SkyLine index error: no such segment: " << i;
45 return dms();
46 }
47
48 SkyPoint *p1 = m_pList[i];
49 SkyPoint *p2 = m_pList[i + 1];
50 double dalpha = p1->ra().radians() - p2->ra().radians();
51 double ddelta = p1->dec().radians() - p2->dec().radians();
52
53 double sa = sin(dalpha / 2.);
54 double sd = sin(ddelta / 2.);
55
56 double hava = sa * sa;
57 double havd = sd * sd;
58
59 double aux = havd + cos(p1->dec().radians()) * cos(p2->dec().radians()) * hava;
60
62 angDist.setRadians(2 * fabs(asin(sqrt(aux))));
63
64 return angDist;
65}
66
67void SkyLine::update(KStarsData *d, KSNumbers *num)
68{
69 foreach (SkyPoint *p, m_pList)
70 {
71 if (num)
72 p->updateCoords(num);
73 p->EquatorialToHorizontal(d->lst(), d->geo()->lat());
74 }
75}
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
void setPoint(int i, SkyPoint *p)
Set point i in the SkyLine.
Definition skyline.cpp:30
void clear()
Remove all points from list.
Definition skyline.cpp:19
void append(SkyPoint *p)
Append a segment to the list by adding a new endpoint.
Definition skyline.cpp:25
dms angularSize(int i=0) const
Definition skyline.cpp:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
virtual void updateCoords(const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0),...
Definition skypoint.cpp:582
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
void append(QList< T > &&value)
void clear()
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.