Kstars

skyline.cpp
1 /*
2  SPDX-FileCopyrightText: 2006 Jason Harris <[email protected]>
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 
14 SkyLine::~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 
30 void SkyLine::setPoint(int i, SkyPoint *p)
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 
61  dms angDist;
62  angDist.setRadians(2 * fabs(asin(sqrt(aux))));
63 
64  return angDist;
65 }
66 
67 void 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 }
void append(const T &value)
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
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
dms angularSize(int i=0) const
Definition: skyline.cpp:40
int size() const const
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
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms & dec() const
Definition: skypoint.h:269
void clear()
Remove all points from list.
Definition: skyline.cpp:19
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
virtual void setRadians(const double &Rad)
Set angle according to the argument, in radians.
Definition: dms.h:333
const CachingDms & ra() const
Definition: skypoint.h:263
double radians() const
Express the angle in radians.
Definition: dms.h:325
void clear()
void setPoint(int i, SkyPoint *p)
Set point i in the SkyLine.
Definition: skyline.cpp:30
void append(SkyPoint *p)
Append a segment to the list by adding a new endpoint.
Definition: skyline.cpp:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 04:05:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.