Kstars

skypoint.h
1/*
2 SPDX-FileCopyrightText: 2001-2005 Jason Harris <jharris@30doradus.org>
3 SPDX-FileCopyrightText: 2004-2005 Pablo de Vicente <p.devicente@wanadoo.es>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "cachingdms.h"
11#include "kstarsdatetime.h"
12
13#include <QList>
14#ifndef KSTARS_LITE
15#include <QtDBus/QDBusArgument>
16#endif
17
18//#define PROFILE_COORDINATE_CONVERSION
19
20class KSNumbers;
21class KSSun;
22class GeoLocation;
23
24/**
25 * @class SkyPoint
26 *
27 * The sky coordinates of a point in the sky. The
28 * coordinates are stored in both Equatorial (Right Ascension,
29 * Declination) and Horizontal (Azimuth, Altitude) coordinate systems.
30 * Provides set/get functions for each coordinate angle, and functions
31 * to convert between the Equatorial and Horizon coordinate systems.
32 *
33 * Because the coordinate values change slowly over time (due to
34 * precession, nutation), the "catalog coordinates" are stored
35 * (RA0, Dec0), which were the true coordinates on Jan 1, 2000.
36 * The true coordinates (RA, Dec) at any other epoch can be found
37 * from the catalog coordinates using updateCoords().
38 * @short Stores dms coordinates for a point in the sky.
39 * for converting between coordinate systems.
40 *
41 * @author Jason Harris
42 * @version 1.0
43 */
45{
46 public:
47 /**
48 * Default constructor: Sets RA, Dec and RA0, Dec0 according
49 * to arguments. Does not set Altitude or Azimuth.
50 *
51 * @param r Right Ascension
52 * @param d Declination
53 */
54 SkyPoint(const dms &r, const dms &d) : RA0(r), Dec0(d), RA(r), Dec(d), lastPrecessJD(J2000) {}
55
56 SkyPoint(const CachingDms &r, const CachingDms &d) : RA0(r), Dec0(d), RA(r), Dec(d), lastPrecessJD(J2000) {}
57
58 /**
59 * Alternate constructor using double arguments, for convenience.
60 * It behaves essentially like the default constructor.
61 *
62 * @param r Right Ascension, expressed as a double
63 * @param d Declination, expressed as a double
64 * @note This also sets RA0 and Dec0
65 */
66 //FIXME: this (*15.0) thing is somewhat hacky.
67 explicit SkyPoint(double r, double d) : RA0(r * 15.0), Dec0(d), RA(r * 15.0), Dec(d), lastPrecessJD(J2000) {}
68
69 /** @short Default constructor. Sets nonsense values for RA, Dec etc */
70 SkyPoint();
71
72 virtual ~SkyPoint() = default;
73
74 ////
75 //// 1. Setting Coordinates
76 //// =======================
77
78 /**
79 * @short Sets RA, Dec and RA0, Dec0 according to arguments.
80 * Does not set Altitude or Azimuth.
81 *
82 * @param r Right Ascension
83 * @param d Declination
84 * @note This function also sets RA0 and Dec0 to the same values, so call at your own peril!
85 * @note FIXME: This method must be removed, or an epoch argument must be added.
86 */
87 void set(const dms &r, const dms &d);
88
89 /**
90 * Sets RA0, the catalog Right Ascension.
91 *
92 * @param r catalog Right Ascension.
93 */
94 inline void setRA0(dms r)
95 {
96 RA0 = r;
97 }
98 inline void setRA0(CachingDms r)
99 {
100 RA0 = r;
101 }
102
103 /**
104 * Overloaded member function, provided for convenience.
105 * It behaves essentially like the above function.
106 *
107 * @param r Right Ascension, expressed as a double.
108 */
109 inline void setRA0(double r)
110 {
111 RA0.setH(r);
112 }
113
114 /**
115 * Sets Dec0, the catalog Declination.
116 *
117 * @param d catalog Declination.
118 */
119 inline void setDec0(dms d)
120 {
121 Dec0 = d;
122 }
123 inline void setDec0(const CachingDms &d)
124 {
125 Dec0 = d;
126 }
127
128 /**
129 * Overloaded member function, provided for convenience.
130 * It behaves essentially like the above function.
131 *
132 * @param d Declination, expressed as a double.
133 */
134 inline void setDec0(double d)
135 {
136 Dec0.setD(d);
137 }
138
139 /**
140 * Sets RA, the current Right Ascension.
141 *
142 * @param r Right Ascension.
143 */
144 inline void setRA(dms &r)
145 {
146 RA = r;
147 }
148 inline void setRA(const CachingDms &r)
149 {
150 RA = r;
151 }
152
153 /**
154 * Overloaded member function, provided for convenience.
155 * It behaves essentially like the above function.
156 *
157 * @param r Right Ascension, expressed as a double.
158 */
159 inline void setRA(double r)
160 {
161 RA.setH(r);
162 }
163
164 /**
165 * Sets Dec, the current Declination
166 *
167 * @param d Declination.
168 */
169 inline void setDec(dms d)
170 {
171 Dec = d;
172 }
173 inline void setDec(const CachingDms &d)
174 {
175 Dec = d;
176 }
177
178 /**
179 * Overloaded member function, provided for convenience.
180 * It behaves essentially like the above function.
181 *
182 * @param d Declination, expressed as a double.
183 */
184 inline void setDec(double d)
185 {
186 Dec.setD(d);
187 }
188
189 /**
190 * Sets Alt, the Altitude.
191 *
192 * @param alt Altitude.
193 */
194 inline void setAlt(dms alt)
195 {
196 Alt = alt;
197 }
198
199 /**
200 * Sets the apparent altitude, checking whether refraction corrections are enabled
201 *
202 * @param alt_apparent Apparent altitude (subject to Options::useRefraction())
203 */
204 void setAltRefracted(dms alt_apparent);
205
206 /**
207 * Overloaded member function, provided for convenience.
208 * It behaves essentially like the above function.
209 *
210 * @param alt_apparent Apparent altitude (subject to Options::useRefraction())
211 */
212 void setAltRefracted(double alt_apparent);
213
214 /**
215 * Overloaded member function, provided for convenience.
216 * It behaves essentially like the above function.
217 *
218 * @param alt Altitude, expressed as a double.
219 */
220 inline void setAlt(double alt)
221 {
222 Alt.setD(alt);
223 }
224
225 /**
226 * Sets Az, the Azimuth.
227 *
228 * @param az Azimuth.
229 */
230 inline void setAz(dms az)
231 {
232 Az = az;
233 }
234
235 /**
236 * Overloaded member function, provided for convenience.
237 * It behaves essentially like the above function.
238 *
239 * @param az Azimuth, expressed as a double.
240 */
241 inline void setAz(double az)
242 {
243 Az.setD(az);
244 }
245
246 ////
247 //// 2. Returning coordinates.
248 //// =========================
249
250 /** @return a pointer to the catalog Right Ascension. */
251 inline const CachingDms &ra0() const
252 {
253 return RA0;
254 }
255
256 /** @return a pointer to the catalog Declination. */
257 inline const CachingDms &dec0() const
258 {
259 return Dec0;
260 }
261
262 /** @returns a pointer to the current Right Ascension. */
263 inline const CachingDms &ra() const
264 {
265 return RA;
266 }
267
268 /** @return a pointer to the current Declination. */
269 inline const CachingDms &dec() const
270 {
271 return Dec;
272 }
273
274 /** @return a pointer to the current Azimuth. */
275 inline const dms &az() const
276 {
277 return Az;
278 }
279
280 /** @return a pointer to the current Altitude. */
281 inline const dms &alt() const
282 {
283 return Alt;
284 }
285
286 /**
287 * @return refracted altitude. This function uses
288 * Options::useRefraction to determine whether refraction
289 * correction should be applied
290 */
291 dms altRefracted() const;
292
293 /** @return the JD for the precessed coordinates */
294 inline long double getLastPrecessJD() const
295 {
296 return lastPrecessJD;
297 }
298
299 /**
300 * @return the airmass of the point. Convenience method.
301 * @note Question: is it better to use alt or refracted alt? Minor difference, probably doesn't matter.
302 */
303 inline double airmass() const
304 {
305 return 1. / sin(alt().radians());
306 }
307
308 /**
309 * @brief isValid Check if the RA and DE fall within expected range
310 * @return True if valid, false otherwise.
311 */
312 inline bool isValid() const
313 {
314 return RA.Hours() >= 0 && RA.Hours() < 24 && Dec.Degrees() >= -90 && Dec.Degrees() <= 90;
315 }
316
317 ////
318 //// 3. Coordinate conversions.
319 //// ==========================
320
321 /**
322 * Determine the (Altitude, Azimuth) coordinates of the
323 * SkyPoint from its (RA, Dec) coordinates, given the local
324 * sidereal time and the observer's latitude.
325 * @param LST pointer to the local sidereal time
326 * @param lat pointer to the geographic latitude
327 */
328 void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat);
329
330 // Deprecated method provided for compatibility
331 void EquatorialToHorizontal(const dms *LST, const dms *lat);
332
333 /**
334 * Determine the (RA, Dec) coordinates of the
335 * SkyPoint from its (Altitude, Azimuth) coordinates, given the local
336 * sidereal time and the observer's latitude.
337 *
338 * @param LST pointer to the local sidereal time
339 * @param lat pointer to the geographic latitude
340 */
341 void HorizontalToEquatorial(const dms *LST, const dms *lat);
342
343 /**
344 * Determine the (RA, Dec) coordinates of the
345 * SkyPoint from its (Altitude, Azimuth) coordinates, given the local
346 * sidereal time and the observer's latitude. Also update (RA0, Dec0)
347 * by calling @see `catalogueCoord` with the given @p jdf
348 *
349 * @param LST pointer to the local sidereal time
350 * @param lat pointer to the geographic latitude
351 * @param jdf Julian date of the present frame
352 */
353 void HorizontalToEquatorialICRS(const dms *LST, const dms *lat, const long double jdf);
354
355 /**
356 * Convenience method for Horizontal -> Equatorial at simulation time
357 *
358 * @note KStarsData::Instance() must exist for this to not crash
359 */
361
362 /**
363 * Determine the Ecliptic coordinates of the SkyPoint, given the Julian Date.
364 * The ecliptic coordinates are returned as reference arguments (since
365 * they are not stored internally)
366 */
367 void findEcliptic(const CachingDms *Obliquity, dms &EcLong, dms &EcLat);
368
369 /**
370 * Set the current (RA, Dec) coordinates of the
371 * SkyPoint, given pointers to its Ecliptic (Long, Lat) coordinates, and
372 * to the current obliquity angle (the angle between the equator and ecliptic).
373 */
374 void setFromEcliptic(const CachingDms *Obliquity, const dms &EcLong, const dms &EcLat);
375
376 /**
377 * Computes galactic coordinates from equatorial coordinates referred to
378 * epoch 1950. RA and Dec are, therefore assumed to be B1950 coordinates.
379 */
380 void Equatorial1950ToGalactic(dms &galLong, dms &galLat);
381
382 /**
383 * Computes equatorial coordinates referred to 1950 from galactic ones referred to
384 * epoch B1950. RA and Dec are, therefore assumed to be B1950 coordinates.
385 */
386 void GalacticToEquatorial1950(const dms *galLong, const dms *galLat);
387
388 ////
389 //// 4. Coordinate update/corrections.
390 //// =================================
391
392 /**
393 * Determine the current coordinates (RA, Dec) from the catalog
394 * coordinates (RA0, Dec0), accounting for both precession and nutation.
395 * @param num pointer to KSNumbers object containing current values of time-dependent variables.
396 * @param includePlanets does nothing in this implementation (see KSPlanetBase::updateCoords()).
397 * @param lat does nothing in this implementation (see KSPlanetBase::updateCoords()).
398 * @param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
399 * @param forceRecompute reapplies precession, nutation and aberration even if the time passed
400 * since the last computation is not significant.
401 */
402 virtual void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = nullptr,
403 const CachingDms *LST = nullptr, bool forceRecompute = false);
404
405 /**
406 * @brief updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, nullptr, nullptr, true)
407 *
408 * @param num pointer to KSNumbers object containing current values of time-dependent variables.
409 */
410 virtual void updateCoordsNow(const KSNumbers *num)
411 {
412 updateCoords(num, false, nullptr, nullptr, true);
413 }
414
415 /**
416 * Computes the apparent coordinates for this SkyPoint for any epoch,
417 * accounting for the effects of precession, nutation, and aberration.
418 * Similar to updateCoords(), but the starting epoch need not be
419 * J2000, and the target epoch need not be the present time.
420 *
421 * @param jd0 Julian Day which identifies the original epoch
422 * @param jdf Julian Day which identifies the final epoch
423 */
424 void apparentCoord(long double jd0, long double jdf);
425
426 /**
427 * Computes the J2000.0 catalogue coordinates for this SkyPoint using the epoch
428 * removing aberration, nutation and precession
429 * Catalogue coordinates are in Ra0, Dec0 as well as Ra, Dec and lastPrecessJD is set to J2000.0
430 *
431 * @FIXME We do not undo nutation and aberration
432 * @brief catalogueCoord converts observed to J2000 using epoch jdf
433 * @param jdf Julian Day which identifies the current epoch
434 * @return SpyPoint containing J2000 coordinates
435 */
436
437 SkyPoint catalogueCoord(long double jdf);
438
439
440 /**
441 * Apply the effects of nutation to this SkyPoint.
442 *
443 * @param num pointer to KSNumbers object containing current values of
444 * time-dependent variables.
445 * @param reverse bool, if true the nutation is removed
446 */
447 void nutate(const KSNumbers *num, const bool reverse = false);
448
449 /**
450 * @short Check if this sky point is close enough to the sun for
451 * gravitational lensing to be significant
452 */
453 bool checkBendLight();
454
455 /**
456 * Correct for the effect of "bending" of light around the sun for
457 * positions near the sun.
458 *
459 * General Relativity tells us that a photon with an impact
460 * parameter b is deflected through an angle 1.75" (Rs / b) where
461 * Rs is the solar radius.
462 *
463 * @return: true if the light was bent, false otherwise
464 */
465 bool bendlight();
466
467 /**
468 * @short Obtain a Skypoint with RA0 and Dec0 set from the RA, Dec
469 * of this skypoint. Also set the RA0, Dec0 of this SkyPoint if not
470 * set already and the target epoch is J2000.
471 */
472 SkyPoint deprecess(const KSNumbers *num, long double epoch = J2000);
473
474 /**
475 * Determine the effects of aberration for this SkyPoint.
476 *
477 * @param num pointer to KSNumbers object containing current values of
478 * time-dependent variables.
479 * @param reverse bool, if true the aberration is removed.
480 */
481 void aberrate(const KSNumbers *num, bool reverse = false);
482
483 /**
484 * General case of precession. It precess from an original epoch to a
485 * final epoch. In this case RA0, and Dec0 from SkyPoint object represent
486 * the coordinates for the original epoch and not for J2000, as usual.
487 *
488 * @param jd0 Julian Day which identifies the original epoch
489 * @param jdf Julian Day which identifies the final epoch
490 */
491 void precessFromAnyEpoch(long double jd0, long double jdf);
492
493 /**
494 * Determine the E-terms of aberration
495 * In the past, the mean places of stars published in catalogs included
496 * the contribution to the aberration due to the ellipticity of the orbit
497 * of the Earth. These terms, known as E-terms were almost constant, and
498 * in the newer catalogs (FK5) are not included. Therefore to convert from
499 * FK4 to FK5 one has to compute these E-terms.
500 */
501 SkyPoint Eterms(void);
502
503 /**
504 * Exact precession from Besselian epoch 1950 to epoch J2000. The
505 * coordinates referred to the first epoch are in the
506 * FK4 catalog, while the latter are in the Fk5 one.
507 *
508 * Reference: Smith, C. A.; Kaplan, G. H.; Hughes, J. A.; Seidelmann,
509 * P. K.; Yallop, B. D.; Hohenkerk, C. Y.
510 * Astronomical Journal, vol. 97, Jan. 1989, p. 265-279
511 *
512 * This transformation requires 4 steps:
513 * - Correct E-terms
514 * - Precess from B1950 to 1984, January 1st, 0h, using Newcomb expressions
515 * - Add zero point correction in right ascension for 1984
516 * - Precess from 1984, January 1st, 0h to J2000
517 */
518 void B1950ToJ2000(void);
519
520 /**
521 * Exact precession from epoch J2000 Besselian epoch 1950. The coordinates
522 * referred to the first epoch are in the FK4 catalog, while the
523 * latter are in the Fk5 one.
524 *
525 * Reference: Smith, C. A.; Kaplan, G. H.; Hughes, J. A.; Seidelmann,
526 * P. K.; Yallop, B. D.; Hohenkerk, C. Y.
527 * Astronomical Journal, vol. 97, Jan. 1989, p. 265-279
528 *
529 * This transformation requires 4 steps:
530 * - Precess from J2000 to 1984, January 1st, 0h
531 * - Add zero point correction in right ascension for 1984
532 * - Precess from 1984, January 1st, 0h, to B1950 using Newcomb expressions
533 * - Correct E-terms
534 */
535 void J2000ToB1950(void);
536
537 /**
538 * Coordinates in the FK4 catalog include the effect of aberration due
539 * to the ellipticity of the orbit of the Earth. Coordinates in the FK5
540 * catalog do not include these terms. In order to convert from B1950 (FK4)
541 * to actual mean places one has to use this function.
542 */
543 void addEterms(void);
544
545 /**
546 * Coordinates in the FK4 catalog include the effect of aberration due
547 * to the ellipticity of the orbit of the Earth. Coordinates in the FK5
548 * catalog do not include these terms. In order to convert from
549 * FK5 coordinates to B1950 (FK4) one has to use this function.
550 */
551 void subtractEterms(void);
552
553 /**
554 * Computes the angular distance between two SkyObjects. The algorithm
555 * to compute this distance is:
556 * cos(distance) = sin(d1)*sin(d2) + cos(d1)*cos(d2)*cos(a1-a2)
557 * where a1,d1 are the coordinates of the first object and a2,d2 are
558 * the coordinates of the second object.
559 * However this algorithm is not accurate when the angular separation is small.
560 * Meeus provides a different algorithm in page 111 which we implement here.
561 *
562 * @param sp SkyPoint to which distance is to be calculated
563 * @param positionAngle if a non-null pointer is passed, the position angle [E of N]
564 * in degrees from this SkyPoint to sp is computed and stored in the passed variable.
565 * @return dms angle representing angular separation.
566 **/
567 dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle = nullptr) const;
568
569 /** @return returns true if _current_ epoch RA / Dec match */
570 inline bool operator==(SkyPoint &p) const
571 {
572 return (ra() == p.ra() && dec() == p.dec());
573 }
574
575 /**
576 * Computes the velocity of the Sun projected on the direction of the source.
577 *
578 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
579 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
580 **/
581 double vRSun(long double jd);
582
583 /**
584 * Computes the radial velocity of a source referred to the solar system barycenter
585 * from the radial velocity referred to the
586 * Local Standard of Rest, aka known as VLSR. To compute it we need the coordinates of the
587 * source the VLSR and the epoch for the source coordinates.
588 *
589 * @param vlsr radial velocity of the source referred to the LSR in km/s
590 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
591 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
592 **/
593 double vHeliocentric(double vlsr, long double jd);
594
595 /**
596 * Computes the radial velocity of a source referred to the Local Standard of Rest, also known as VLSR
597 * from the radial velocity referred to the solar system barycenter
598 *
599 * @param vhelio radial velocity of the source referred to the LSR in km/s
600 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
601 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
602 **/
603 double vHelioToVlsr(double vhelio, long double jd);
604
605 /**
606 * Computes the velocity of any object projected on the direction of the source.
607 *
608 * @param jd0 Julian day for which we compute the direction of the source
609 * @return velocity of the Earth projected on the direction of the source kms-1
610 */
611 double vREarth(long double jd0);
612
613 /**
614 * Computes the radial velocity of a source referred to the center of the earth
615 * from the radial velocity referred to the solar system barycenter
616 *
617 * @param vhelio radial velocity of the source referred to the barycenter of the
618 * solar system in km/s
619 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
620 * @return Radial velocity of the source referred to the center of the Earth in km/s
621 **/
622 double vGeocentric(double vhelio, long double jd);
623
624 /**
625 * Computes the radial velocity of a source referred to the solar system barycenter
626 * from the velocity referred to the center of the earth
627 *
628 * @param vgeo radial velocity of the source referred to the center of the Earth [km/s]
629 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
630 * @return Radial velocity of the source referred to the solar system barycenter in km/s
631 **/
632 double vGeoToVHelio(double vgeo, long double jd);
633
634 /**
635 * Computes the velocity of any object (observer's site) projected on the
636 * direction of the source.
637 *
638 * @param vsite velocity of that object in cartesian coordinates
639 * @return velocity of the object projected on the direction of the source kms-1
640 */
641 double vRSite(double vsite[3]);
642
643 /**
644 * Computes the radial velocity of a source referred to the observer site on the surface
645 * of the earth from the geocentric velocity and the velocity of the site referred to the center
646 * of the Earth.
647 *
648 * @param vgeo radial velocity of the source referred to the center of the earth in km/s
649 * @param vsite Velocity at which the observer moves referred to the center of the earth.
650 * @return Radial velocity of the source referred to the observer's site in km/s
651 **/
652 double vTopocentric(double vgeo, double vsite[3]);
653
654 /**
655 * Computes the radial velocity of a source referred to the center of the Earth from
656 * the radial velocity referred to an observer site on the surface of the earth
657 *
658 * @param vtopo radial velocity of the source referred to the observer's site in km/s
659 * @param vsite Velocity at which the observer moves referred to the center of the earth.
660 * @return Radial velocity of the source referred the center of the earth in km/s
661 **/
662 double vTopoToVGeo(double vtopo, double vsite[3]);
663
664 /**
665 * Find the SkyPoint obtained by moving distance dist
666 * (arcseconds) away from the givenSkyPoint
667 *
668 * @param dist Distance to move through in arcseconds
669 * @param from The SkyPoint to move away from
670 * @return a SkyPoint that is at the dist away from this SkyPoint in the direction away from
671 */
672 SkyPoint moveAway(const SkyPoint &from, double dist) const;
673
674 /** @short Check if this point is circumpolar at the given geographic latitude */
675 bool checkCircumpolar(const dms *gLat) const;
676
677 /** Calculate refraction correction. Parameter and return value are in degrees */
678 static double refractionCorr(double alt);
679
680 /**
681 * @short Apply refraction correction to altitude, depending on conditional
682 *
683 * @param alt altitude to be corrected, in degrees
684 * @param conditional an optional boolean to decide whether to apply the correction or not
685 * @note If conditional is false, this method returns its argument unmodified. This is a convenience feature as it is often needed to gate these corrections.
686 * @return altitude after refraction correction (if applicable), in degrees
687 */
688 static double refract(const double alt, bool conditional = true);
689
690 /**
691 * @short Remove refraction correction, depending on conditional
692 *
693 * @param alt altitude from which refraction correction must be removed, in degrees
694 * @param conditional an optional boolean to decide whether to undo the correction or not
695 * @return altitude without refraction correction, in degrees
696 * @note If conditional is false, this method returns its argument unmodified. This is a convenience feature as it is often needed to gate these corrections.
697 */
698 static double unrefract(const double alt, bool conditional = true);
699
700 /**
701 * @short Apply refraction correction to altitude. Overloaded method using
702 * dms provided for convenience
703 * @see SkyPoint::refract( const double alt )
704 */
705 static inline dms refract(const dms alt, bool conditional = true)
706 {
707 return dms(refract(alt.Degrees(), conditional));
708 }
709
710 /**
711 * @short Remove refraction correction. Overloaded method using
712 * dms provided for convenience
713 * @see SkyPoint::unrefract( const double alt )
714 */
715 static inline dms unrefract(const dms alt, bool conditional = true)
716 {
717 return dms(unrefract(alt.Degrees(), conditional));
718 }
719
720 /**
721 * @short Compute the altitude of a given skypoint hour hours from the given date/time
722 *
723 * @param p SkyPoint whose altitude is to be computed (const pointer, the method works on a clone)
724 * @param dt Date/time that corresponds to 0 hour
725 * @param geo GeoLocation object specifying the location
726 * @param hour double specifying offset in hours from dt for which altitude is to be found
727 * @return a dms containing (unrefracted?) altitude of the object at dt + hour hours at the given location
728 *
729 * @note This method is used in multiple places across KStars
730 * @todo Fix code duplication in AltVsTime and KSAlmanac by using this method instead! FIXME.
731 */
732 static dms findAltitude(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour = 0);
733
734 /**
735 * @short returns a time-transformed SkyPoint. See SkyPoint::findAltitude() for details
736 * @todo Fix this documentation.
737 */
738 static SkyPoint timeTransformed(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo,
739 const double hour = 0);
740
741 /**
742 * @short Critical height for atmospheric refraction
743 * corrections. Below this, the height formula produces meaningless
744 * results and the correction value is just interpolated.
745 */
746 static const double altCrit;
747
748 /**
749 * @short Return the object's altitude at the upper culmination for the given latitude
750 *
751 * @return the maximum altitude in degrees
752 */
753 double maxAlt(const dms &lat) const;
754
755 /**
756 * @short Return the object's altitude at the lower culmination for the given latitude
757 *
758 * @return the minimum altitude in degrees
759 */
760 double minAlt(const dms &lat) const;
761
762 /**
763 * @short Return the Parallactic Angle
764 *
765 * The parallactic angle is the angle between "up" and
766 * "north". See Jean Meeus' "Astronomical Algorithms" second
767 * edition, Chapter 14 for more details (especially Fig 4 on Pg
768 * 99). The angle returned in this case, between a vector of
769 * increasing altitude and a vector of increasing declination, is
770 * measured in the clockwise sense as seen on the sky.
771 *
772 * @param LST Local Sidereal Time
773 * @param lat Latitude
774 *
775 * @note EquatorialToHorizontal() need not be called before
776 * invoking this, but it is wise to call updateCoords() to ensure
777 * ra() and dec() refer to the right epoch.
778 *
779 * @return the parallactic angle in the clockwise sense
780 */
781 dms parallacticAngle(const CachingDms &LST, const CachingDms &lat);
782
783#ifdef PROFILE_COORDINATE_CONVERSION
784 static double cpuTime_EqToHz;
785 static long unsigned eqToHzCalls;
786#endif
787 static bool implementationIsLibnova;
788
789 protected:
790 /**
791 * Precess this SkyPoint's catalog coordinates to the epoch described by the
792 * given KSNumbers object.
793 *
794 * @param num pointer to a KSNumbers object describing the target epoch.
795 */
796 void precess(const KSNumbers *num);
797
798#ifdef UNIT_TEST
799 friend class TestSkyPoint; // Test class
800#endif
801
802 private:
803 CachingDms RA0, Dec0; //catalog coordinates
804 CachingDms RA, Dec; //current true sky coordinates
805 dms Alt, Az;
806 static KSSun *m_Sun;
807
808
809 // long version of these epochs
810#define J2000L 2451545.0L //Julian Date for noon on Jan 1, 2000 (epoch J2000)
811#define B1950L 2433282.4235L // Julian date for Jan 0.9235, 1950
812
813 protected:
814 long double lastPrecessJD { 0 }; // JD at which the last coordinate (see updateCoords) for this SkyPoint was done
815};
816
817#ifndef KSTARS_LITE
818Q_DECLARE_METATYPE(SkyPoint)
819QDBusArgument &operator<<(QDBusArgument &argument, const SkyPoint &source);
820const QDBusArgument &operator>>(const QDBusArgument &argument, SkyPoint &dest);
821#endif
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition cachingdms.h:19
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition kssun.h:24
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
The sky coordinates of a point in the sky.
Definition skypoint.h:45
double maxAlt(const dms &lat) const
Return the object's altitude at the upper culmination for the given latitude.
double airmass() const
Definition skypoint.h:303
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
Definition skypoint.cpp:720
void setDec(double d)
Overloaded member function, provided for convenience.
Definition skypoint.h:184
static double refract(const double alt, bool conditional=true)
Apply refraction correction to altitude, depending on conditional.
static const double altCrit
Critical height for atmospheric refraction corrections.
Definition skypoint.h:746
void aberrate(const KSNumbers *num, bool reverse=false)
Determine the effects of aberration for this SkyPoint.
Definition skypoint.cpp:474
void precessFromAnyEpoch(long double jd0, long double jdf)
General case of precession.
Definition skypoint.cpp:645
static double refractionCorr(double alt)
Calculate refraction correction.
const CachingDms & dec() const
Definition skypoint.h:269
void setAltRefracted(dms alt_apparent)
Sets the apparent altitude, checking whether refraction corrections are enabled.
SkyPoint(const dms &r, const dms &d)
Default constructor: Sets RA, Dec and RA0, Dec0 according to arguments.
Definition skypoint.h:54
double minAlt(const dms &lat) const
Return the object's altitude at the lower culmination for the given latitude.
double vREarth(long double jd0)
Computes the velocity of any object projected on the direction of the source.
void setAz(double az)
Overloaded member function, provided for convenience.
Definition skypoint.h:241
const CachingDms & ra0() const
Definition skypoint.h:251
void setDec(dms d)
Sets Dec, the current Declination.
Definition skypoint.h:169
bool checkCircumpolar(const dms *gLat) const
Check if this point is circumpolar at the given geographic latitude.
virtual void updateCoordsNow(const KSNumbers *num)
updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, nullptr, nullptr,...
Definition skypoint.h:410
void setRA(dms &r)
Sets RA, the current Right Ascension.
Definition skypoint.h:144
const CachingDms & ra() const
Definition skypoint.h:263
static dms findAltitude(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour=0)
Compute the altitude of a given skypoint hour hours from the given date/time.
void setAlt(double alt)
Overloaded member function, provided for convenience.
Definition skypoint.h:220
dms altRefracted() const
void precess(const KSNumbers *num)
Precess this SkyPoint's catalog coordinates to the epoch described by the given KSNumbers object.
Definition skypoint.cpp:243
static SkyPoint timeTransformed(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour=0)
returns a time-transformed SkyPoint.
void findEcliptic(const CachingDms *Obliquity, dms &EcLong, dms &EcLat)
Determine the Ecliptic coordinates of the SkyPoint, given the Julian Date.
Definition skypoint.cpp:207
void HorizontalToEquatorialNow()
Convenience method for Horizontal -> Equatorial at simulation time.
Definition skypoint.cpp:199
void addEterms(void)
Coordinates in the FK4 catalog include the effect of aberration due to the ellipticity of the orbit o...
Definition skypoint.cpp:903
double vGeoToVHelio(double vgeo, long double jd)
Computes the radial velocity of a source referred to the solar system barycenter from the velocity re...
void nutate(const KSNumbers *num, const bool reverse=false)
Apply the effects of nutation to this SkyPoint.
Definition skypoint.cpp:295
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
Definition skypoint.cpp:919
long double getLastPrecessJD() const
Definition skypoint.h:294
double vTopoToVGeo(double vtopo, double vsite[3])
Computes the radial velocity of a source referred to the center of the Earth from the radial velocity...
void B1950ToJ2000(void)
Exact precession from Besselian epoch 1950 to epoch J2000.
Definition skypoint.cpp:793
bool bendlight()
Correct for the effect of "bending" of light around the sun for positions near the sun.
Definition skypoint.cpp:445
void setFromEcliptic(const CachingDms *Obliquity, const dms &EcLong, const dms &EcLat)
Set the current (RA, Dec) coordinates of the SkyPoint, given pointers to its Ecliptic (Long,...
Definition skypoint.cpp:221
SkyPoint moveAway(const SkyPoint &from, double dist) const
Find the SkyPoint obtained by moving distance dist (arcseconds) away from the givenSkyPoint.
Definition skypoint.cpp:391
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
double vRSite(double vsite[3])
Computes the velocity of any object (observer's site) projected on the direction of the source.
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition skypoint.h:94
static double unrefract(const double alt, bool conditional=true)
Remove refraction correction, depending on conditional.
double vRSun(long double jd)
Computes the velocity of the Sun projected on the direction of the source.
Definition skypoint.cpp:954
void HorizontalToEquatorialICRS(const dms *LST, const dms *lat, const long double jdf)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition skypoint.cpp:187
const dms & az() const
Definition skypoint.h:275
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:602
void setRA(double r)
Overloaded member function, provided for convenience.
Definition skypoint.h:159
void setRA0(double r)
Overloaded member function, provided for convenience.
Definition skypoint.h:109
void set(const dms &r, const dms &d)
Sets RA, Dec and RA0, Dec0 according to arguments.
Definition skypoint.cpp:63
double vTopocentric(double vgeo, double vsite[3])
Computes the radial velocity of a source referred to the observer site on the surface of the earth fr...
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition skypoint.h:194
static dms unrefract(const dms alt, bool conditional=true)
Remove refraction correction.
Definition skypoint.h:715
double vHeliocentric(double vlsr, long double jd)
Computes the radial velocity of a source referred to the solar system barycenter from the radial velo...
Definition skypoint.cpp:992
const dms & alt() const
Definition skypoint.h:281
static dms refract(const dms alt, bool conditional=true)
Apply refraction correction to altitude.
Definition skypoint.h:705
bool operator==(SkyPoint &p) const
Definition skypoint.h:570
SkyPoint(double r, double d)
Alternate constructor using double arguments, for convenience.
Definition skypoint.h:67
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition skypoint.cpp:143
bool checkBendLight()
Check if this sky point is close enough to the sun for gravitational lensing to be significant.
Definition skypoint.cpp:419
void setDec0(double d)
Overloaded member function, provided for convenience.
Definition skypoint.h:134
SkyPoint Eterms(void)
Determine the E-terms of aberration In the past, the mean places of stars published in catalogs inclu...
Definition skypoint.cpp:888
void GalacticToEquatorial1950(const dms *galLong, const dms *galLat)
Computes equatorial coordinates referred to 1950 from galactic ones referred to epoch B1950.
Definition skypoint.cpp:774
double vGeocentric(double vhelio, long double jd)
Computes the radial velocity of a source referred to the center of the earth from the radial velocity...
void setAz(dms az)
Sets Az, the Azimuth.
Definition skypoint.h:230
const CachingDms & dec0() const
Definition skypoint.h:257
void J2000ToB1950(void)
Exact precession from epoch J2000 Besselian epoch 1950.
Definition skypoint.cpp:839
double vHelioToVlsr(double vhelio, long double jd)
Computes the radial velocity of a source referred to the Local Standard of Rest, also known as VLSR f...
Definition skypoint.cpp:997
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition skypoint.h:119
SkyPoint()
Default constructor.
Definition skypoint.cpp:53
void subtractEterms(void)
Coordinates in the FK4 catalog include the effect of aberration due to the ellipticity of the orbit o...
Definition skypoint.cpp:911
bool isValid() const
isValid Check if the RA and DE fall within expected range
Definition skypoint.h:312
SkyPoint catalogueCoord(long double jdf)
Computes the J2000.0 catalogue coordinates for this SkyPoint using the epoch removing aberration,...
Definition skypoint.cpp:730
void Equatorial1950ToGalactic(dms &galLong, dms &galLat)
Computes galactic coordinates from equatorial coordinates referred to epoch 1950.
Definition skypoint.cpp:755
dms parallacticAngle(const CachingDms &LST, const CachingDms &lat)
Return the Parallactic Angle.
SkyPoint deprecess(const KSNumbers *num, long double epoch=J2000)
Obtain a Skypoint with RA0 and Dec0 set from the RA, Dec of this skypoint.
Definition skypoint.cpp:277
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:53:02 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.