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 <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 */
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 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 //// 3. Coordinate conversions.
310 //// ==========================
311
312 /**
313 * Determine the (Altitude, Azimuth) coordinates of the
314 * SkyPoint from its (RA, Dec) coordinates, given the local
315 * sidereal time and the observer's latitude.
316 * @param LST pointer to the local sidereal time
317 * @param lat pointer to the geographic latitude
318 */
319 void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat);
320
321 // Deprecated method provided for compatibility
322 void EquatorialToHorizontal(const dms *LST, const dms *lat);
323
324 /**
325 * Determine the (RA, Dec) coordinates of the
326 * SkyPoint from its (Altitude, Azimuth) coordinates, given the local
327 * sidereal time and the observer's latitude.
328 *
329 * @param LST pointer to the local sidereal time
330 * @param lat pointer to the geographic latitude
331 */
332 void HorizontalToEquatorial(const dms *LST, const dms *lat);
333
334 /**
335 * Determine the Ecliptic coordinates of the SkyPoint, given the Julian Date.
336 * The ecliptic coordinates are returned as reference arguments (since
337 * they are not stored internally)
338 */
339 void findEcliptic(const CachingDms *Obliquity, dms &EcLong, dms &EcLat);
340
341 /**
342 * Set the current (RA, Dec) coordinates of the
343 * SkyPoint, given pointers to its Ecliptic (Long, Lat) coordinates, and
344 * to the current obliquity angle (the angle between the equator and ecliptic).
345 */
346 void setFromEcliptic(const CachingDms *Obliquity, const dms &EcLong, const dms &EcLat);
347
348 /**
349 * Computes galactic coordinates from equatorial coordinates referred to
350 * epoch 1950. RA and Dec are, therefore assumed to be B1950 coordinates.
351 */
352 void Equatorial1950ToGalactic(dms &galLong, dms &galLat);
353
354 /**
355 * Computes equatorial coordinates referred to 1950 from galactic ones referred to
356 * epoch B1950. RA and Dec are, therefore assumed to be B1950 coordinates.
357 */
358 void GalacticToEquatorial1950(const dms *galLong, const dms *galLat);
359
360 ////
361 //// 4. Coordinate update/corrections.
362 //// =================================
363
364 /**
365 * Determine the current coordinates (RA, Dec) from the catalog
366 * coordinates (RA0, Dec0), accounting for both precession and nutation.
367 * @param num pointer to KSNumbers object containing current values of time-dependent variables.
368 * @param includePlanets does nothing in this implementation (see KSPlanetBase::updateCoords()).
369 * @param lat does nothing in this implementation (see KSPlanetBase::updateCoords()).
370 * @param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
371 * @param forceRecompute reapplies precession, nutation and aberration even if the time passed
372 * since the last computation is not significant.
373 */
374 virtual void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = nullptr,
375 const CachingDms *LST = nullptr, bool forceRecompute = false);
376
377 /**
378 * @brief updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, nullptr, nullptr, true)
379 *
380 * @param num pointer to KSNumbers object containing current values of time-dependent variables.
381 */
382 virtual void updateCoordsNow(const KSNumbers *num)
383 {
384 updateCoords(num, false, nullptr, nullptr, true);
385 }
386
387 /**
388 * Computes the apparent coordinates for this SkyPoint for any epoch,
389 * accounting for the effects of precession, nutation, and aberration.
390 * Similar to updateCoords(), but the starting epoch need not be
391 * J2000, and the target epoch need not be the present time.
392 *
393 * @param jd0 Julian Day which identifies the original epoch
394 * @param jdf Julian Day which identifies the final epoch
395 */
396 void apparentCoord(long double jd0, long double jdf);
397
398 /**
399 * Computes the J2000.0 catalogue coordinates for this SkyPoint using the epoch
400 * removing aberration, nutation and precession
401 * Catalogue coordinates are in Ra0, Dec0 as well as Ra, Dec and lastPrecessJD is set to J2000.0
402 *
403 * @FIXME We do not undo nutation and aberration
404 * @brief catalogueCoord converts observed to J2000 using epoch jdf
405 * @param jdf Julian Day which identifies the current epoch
406 * @return SpyPoint containing J2000 coordinates
407 */
408
409 SkyPoint catalogueCoord(long double jdf);
410
411
412 /**
413 * Apply the effects of nutation to this SkyPoint.
414 *
415 * @param num pointer to KSNumbers object containing current values of
416 * time-dependent variables.
417 * @param reverse bool, if true the nutation is removed
418 */
419 void nutate(const KSNumbers *num, const bool reverse = false);
420
421 /**
422 * @short Check if this sky point is close enough to the sun for
423 * gravitational lensing to be significant
424 */
425 bool checkBendLight();
426
427 /**
428 * Correct for the effect of "bending" of light around the sun for
429 * positions near the sun.
430 *
431 * General Relativity tells us that a photon with an impact
432 * parameter b is deflected through an angle 1.75" (Rs / b) where
433 * Rs is the solar radius.
434 *
435 * @return: true if the light was bent, false otherwise
436 */
437 bool bendlight();
438
439 /**
440 * @short Obtain a Skypoint with RA0 and Dec0 set from the RA, Dec
441 * of this skypoint. Also set the RA0, Dec0 of this SkyPoint if not
442 * set already and the target epoch is J2000.
443 */
444 SkyPoint deprecess(const KSNumbers *num, long double epoch = J2000);
445
446 /**
447 * Determine the effects of aberration for this SkyPoint.
448 *
449 * @param num pointer to KSNumbers object containing current values of
450 * time-dependent variables.
451 * @param reverse bool, if true the aberration is removed.
452 */
453 void aberrate(const KSNumbers *num, bool reverse = false);
454
455 /**
456 * General case of precession. It precess from an original epoch to a
457 * final epoch. In this case RA0, and Dec0 from SkyPoint object represent
458 * the coordinates for the original epoch and not for J2000, as usual.
459 *
460 * @param jd0 Julian Day which identifies the original epoch
461 * @param jdf Julian Day which identifies the final epoch
462 */
463 void precessFromAnyEpoch(long double jd0, long double jdf);
464
465 /**
466 * Determine the E-terms of aberration
467 * In the past, the mean places of stars published in catalogs included
468 * the contribution to the aberration due to the ellipticity of the orbit
469 * of the Earth. These terms, known as E-terms were almost constant, and
470 * in the newer catalogs (FK5) are not included. Therefore to convert from
471 * FK4 to FK5 one has to compute these E-terms.
472 */
473 SkyPoint Eterms(void);
474
475 /**
476 * Exact precession from Besselian epoch 1950 to epoch J2000. The
477 * coordinates referred to the first epoch are in the
478 * FK4 catalog, while the latter are in the Fk5 one.
479 *
480 * Reference: Smith, C. A.; Kaplan, G. H.; Hughes, J. A.; Seidelmann,
481 * P. K.; Yallop, B. D.; Hohenkerk, C. Y.
482 * Astronomical Journal, vol. 97, Jan. 1989, p. 265-279
483 *
484 * This transformation requires 4 steps:
485 * - Correct E-terms
486 * - Precess from B1950 to 1984, January 1st, 0h, using Newcomb expressions
487 * - Add zero point correction in right ascension for 1984
488 * - Precess from 1984, January 1st, 0h to J2000
489 */
490 void B1950ToJ2000(void);
491
492 /**
493 * Exact precession from epoch J2000 Besselian epoch 1950. The coordinates
494 * referred to the first epoch are in the FK4 catalog, while the
495 * latter are in the Fk5 one.
496 *
497 * Reference: Smith, C. A.; Kaplan, G. H.; Hughes, J. A.; Seidelmann,
498 * P. K.; Yallop, B. D.; Hohenkerk, C. Y.
499 * Astronomical Journal, vol. 97, Jan. 1989, p. 265-279
500 *
501 * This transformation requires 4 steps:
502 * - Precess from J2000 to 1984, January 1st, 0h
503 * - Add zero point correction in right ascension for 1984
504 * - Precess from 1984, January 1st, 0h, to B1950 using Newcomb expressions
505 * - Correct E-terms
506 */
507 void J2000ToB1950(void);
508
509 /**
510 * Coordinates in the FK4 catalog include the effect of aberration due
511 * to the ellipticity of the orbit of the Earth. Coordinates in the FK5
512 * catalog do not include these terms. In order to convert from B1950 (FK4)
513 * to actual mean places one has to use this function.
514 */
515 void addEterms(void);
516
517 /**
518 * Coordinates in the FK4 catalog include the effect of aberration due
519 * to the ellipticity of the orbit of the Earth. Coordinates in the FK5
520 * catalog do not include these terms. In order to convert from
521 * FK5 coordinates to B1950 (FK4) one has to use this function.
522 */
523 void subtractEterms(void);
524
525 /**
526 * Computes the angular distance between two SkyObjects. The algorithm
527 * to compute this distance is:
528 * cos(distance) = sin(d1)*sin(d2) + cos(d1)*cos(d2)*cos(a1-a2)
529 * where a1,d1 are the coordinates of the first object and a2,d2 are
530 * the coordinates of the second object.
531 * However this algorithm is not accurate when the angular separation is small.
532 * Meeus provides a different algorithm in page 111 which we implement here.
533 *
534 * @param sp SkyPoint to which distance is to be calculated
535 * @param positionAngle if a non-null pointer is passed, the position angle [E of N]
536 * in degrees from this SkyPoint to sp is computed and stored in the passed variable.
537 * @return dms angle representing angular separation.
538 **/
539 dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle = nullptr) const;
540
541 /** @return returns true if _current_ epoch RA / Dec match */
542 inline bool operator==(SkyPoint &p) const
543 {
544 return (ra() == p.ra() && dec() == p.dec());
545 }
546
547 /**
548 * Computes the velocity of the Sun projected on the direction of the source.
549 *
550 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
551 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
552 **/
553 double vRSun(long double jd);
554
555 /**
556 * Computes the radial velocity of a source referred to the solar system barycenter
557 * from the radial velocity referred to the
558 * Local Standard of Rest, aka known as VLSR. To compute it we need the coordinates of the
559 * source the VLSR and the epoch for the source coordinates.
560 *
561 * @param vlsr radial velocity of the source referred to the LSR in km/s
562 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
563 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
564 **/
565 double vHeliocentric(double vlsr, long double jd);
566
567 /**
568 * Computes the radial velocity of a source referred to the Local Standard of Rest, also known as VLSR
569 * from the radial velocity referred to the solar system barycenter
570 *
571 * @param vhelio radial velocity of the source referred to the LSR in km/s
572 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
573 * @return Radial velocity of the source referred to the barycenter of the solar system in km/s
574 **/
575 double vHelioToVlsr(double vhelio, long double jd);
576
577 /**
578 * Computes the velocity of any object projected on the direction of the source.
579 *
580 * @param jd0 Julian day for which we compute the direction of the source
581 * @return velocity of the Earth projected on the direction of the source kms-1
582 */
583 double vREarth(long double jd0);
584
585 /**
586 * Computes the radial velocity of a source referred to the center of the earth
587 * from the radial velocity referred to the solar system barycenter
588 *
589 * @param vhelio radial velocity of the source referred to the barycenter of the
590 * solar system in km/s
591 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
592 * @return Radial velocity of the source referred to the center of the Earth in km/s
593 **/
594 double vGeocentric(double vhelio, long double jd);
595
596 /**
597 * Computes the radial velocity of a source referred to the solar system barycenter
598 * from the velocity referred to the center of the earth
599 *
600 * @param vgeo radial velocity of the source referred to the center of the Earth [km/s]
601 * @param jd Epoch expressed as julian day to which the source coordinates refer to.
602 * @return Radial velocity of the source referred to the solar system barycenter in km/s
603 **/
604 double vGeoToVHelio(double vgeo, long double jd);
605
606 /**
607 * Computes the velocity of any object (observer's site) projected on the
608 * direction of the source.
609 *
610 * @param vsite velocity of that object in cartesian coordinates
611 * @return velocity of the object projected on the direction of the source kms-1
612 */
613 double vRSite(double vsite[3]);
614
615 /**
616 * Computes the radial velocity of a source referred to the observer site on the surface
617 * of the earth from the geocentric velocity and the velocity of the site referred to the center
618 * of the Earth.
619 *
620 * @param vgeo radial velocity of the source referred to the center of the earth in km/s
621 * @param vsite Velocity at which the observer moves referred to the center of the earth.
622 * @return Radial velocity of the source referred to the observer's site in km/s
623 **/
624 double vTopocentric(double vgeo, double vsite[3]);
625
626 /**
627 * Computes the radial velocity of a source referred to the center of the Earth from
628 * the radial velocity referred to an observer site on the surface of the earth
629 *
630 * @param vtopo radial velocity of the source referred to the observer's site in km/s
631 * @param vsite Velocity at which the observer moves referred to the center of the earth.
632 * @return Radial velocity of the source referred the center of the earth in km/s
633 **/
634 double vTopoToVGeo(double vtopo, double vsite[3]);
635
636 /**
637 * Find the SkyPoint obtained by moving distance dist
638 * (arcseconds) away from the givenSkyPoint
639 *
640 * @param dist Distance to move through in arcseconds
641 * @param from The SkyPoint to move away from
642 * @return a SkyPoint that is at the dist away from this SkyPoint in the direction away from
643 */
644 SkyPoint moveAway(const SkyPoint &from, double dist) const;
645
646 /** @short Check if this point is circumpolar at the given geographic latitude */
647 bool checkCircumpolar(const dms *gLat) const;
648
649 /** Calculate refraction correction. Parameter and return value are in degrees */
650 static double refractionCorr(double alt);
651
652 /**
653 * @short Apply refraction correction to altitude, depending on conditional
654 *
655 * @param alt altitude to be corrected, in degrees
656 * @param conditional an optional boolean to decide whether to apply the correction or not
657 * @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.
658 * @return altitude after refraction correction (if applicable), in degrees
659 */
660 static double refract(const double alt, bool conditional = true);
661
662 /**
663 * @short Remove refraction correction, depending on conditional
664 *
665 * @param alt altitude from which refraction correction must be removed, in degrees
666 * @param conditional an optional boolean to decide whether to undo the correction or not
667 * @return altitude without refraction correction, in degrees
668 * @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.
669 */
670 static double unrefract(const double alt, bool conditional = true);
671
672 /**
673 * @short Apply refraction correction to altitude. Overloaded method using
674 * dms provided for convenience
675 * @see SkyPoint::refract( const double alt )
676 */
677 static inline dms refract(const dms alt, bool conditional = true)
678 {
679 return dms(refract(alt.Degrees(), conditional));
680 }
681
682 /**
683 * @short Remove refraction correction. Overloaded method using
684 * dms provided for convenience
685 * @see SkyPoint::unrefract( const double alt )
686 */
687 static inline dms unrefract(const dms alt, bool conditional = true)
688 {
689 return dms(unrefract(alt.Degrees(), conditional));
690 }
691
692 /**
693 * @short Compute the altitude of a given skypoint hour hours from the given date/time
694 *
695 * @param p SkyPoint whose altitude is to be computed (const pointer, the method works on a clone)
696 * @param dt Date/time that corresponds to 0 hour
697 * @param geo GeoLocation object specifying the location
698 * @param hour double specifying offset in hours from dt for which altitude is to be found
699 * @return a dms containing (unrefracted?) altitude of the object at dt + hour hours at the given location
700 *
701 * @note This method is used in multiple places across KStars
702 * @todo Fix code duplication in AltVsTime and KSAlmanac by using this method instead! FIXME.
703 */
704 static dms findAltitude(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour = 0);
705
706 /**
707 * @short returns a time-transformed SkyPoint. See SkyPoint::findAltitude() for details
708 * @todo Fix this documentation.
709 */
710 static SkyPoint timeTransformed(const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo,
711 const double hour = 0);
712
713 /**
714 * @short Critical height for atmospheric refraction
715 * corrections. Below this, the height formula produces meaningless
716 * results and the correction value is just interpolated.
717 */
718 static const double altCrit;
719
720 /**
721 * @short Return the object's altitude at the upper culmination for the given latitude
722 *
723 * @return the maximum altitude in degrees
724 */
725 double maxAlt(const dms &lat) const;
726
727 /**
728 * @short Return the object's altitude at the lower culmination for the given latitude
729 *
730 * @return the minimum altitude in degrees
731 */
732 double minAlt(const dms &lat) const;
733
734 /**
735 * @short Return the Parallactic Angle
736 *
737 * The parallactic angle is the angle between "up" and
738 * "north". See Jean Meeus' "Astronomical Algorithms" second
739 * edition, Chapter 14 for more details (especially Fig 4 on Pg
740 * 99). The angle returned in this case, between a vector of
741 * increasing altitude and a vector of increasing declination, is
742 * measured in the clockwise sense as seen on the sky.
743 *
744 * @param LST Local Sidereal Time
745 * @param lat Latitude
746 *
747 * @note EquatorialToHorizontal() need not be called before
748 * invoking this, but it is wise to call updateCoords() to ensure
749 * ra() and dec() refer to the right epoch.
750 *
751 * @return the parallactic angle in the clockwise sense
752 */
753 dms parallacticAngle(const CachingDms &LST, const CachingDms &lat);
754
755#ifdef PROFILE_COORDINATE_CONVERSION
756 static double cpuTime_EqToHz;
757 static long unsigned eqToHzCalls;
758#endif
759 static bool implementationIsLibnova;
760
761 protected:
762 /**
763 * Precess this SkyPoint's catalog coordinates to the epoch described by the
764 * given KSNumbers object.
765 *
766 * @param num pointer to a KSNumbers object describing the target epoch.
767 */
768 void precess(const KSNumbers *num);
769
770#ifdef UNIT_TEST
771 friend class TestSkyPoint; // Test class
772#endif
773
774 private:
775 CachingDms RA0, Dec0; //catalog coordinates
776 CachingDms RA, Dec; //current true sky coordinates
777 dms Alt, Az;
778 static KSSun *m_Sun;
779
780
781 // long version of these epochs
782#define J2000L 2451545.0L //Julian Date for noon on Jan 1, 2000 (epoch J2000)
783#define B1950L 2433282.4235L // Julian date for Jan 0.9235, 1950
784
785 protected:
786 double lastPrecessJD { 0 }; // JD at which the last coordinate (see updateCoords) for this SkyPoint was done
787};
788
789#ifndef KSTARS_LITE
790Q_DECLARE_METATYPE(SkyPoint)
793#endif
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition cachingdms.h:19
void setD(const double &x) override
Sets the angle in degrees supplied as a double.
Definition cachingdms.h:59
void setH(const double &x) override
Sets the angle in hours, supplied as a double.
Definition cachingdms.h:91
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:700
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:718
void aberrate(const KSNumbers *num, bool reverse=false)
Determine the effects of aberration for this SkyPoint.
Definition skypoint.cpp:454
double getLastPrecessJD() const
Definition skypoint.h:294
void precessFromAnyEpoch(long double jd0, long double jdf)
General case of precession.
Definition skypoint.cpp:625
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.
Definition skypoint.cpp:982
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:382
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:223
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:187
void addEterms(void)
Coordinates in the FK4 catalog include the effect of aberration due to the ellipticity of the orbit o...
Definition skypoint.cpp:883
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:275
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
Definition skypoint.cpp:899
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:773
bool bendlight()
Correct for the effect of "bending" of light around the sun for positions near the sun.
Definition skypoint.cpp:425
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:201
SkyPoint moveAway(const SkyPoint &from, double dist) const
Find the SkyPoint obtained by moving distance dist (arcseconds) away from the givenSkyPoint.
Definition skypoint.cpp:371
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:934
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:582
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:687
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:972
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:677
bool operator==(SkyPoint &p) const
Definition skypoint.h:542
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:399
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:868
void GalacticToEquatorial1950(const dms *galLong, const dms *galLat)
Computes equatorial coordinates referred to 1950 from galactic ones referred to epoch B1950.
Definition skypoint.cpp:754
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:819
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:977
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:891
SkyPoint catalogueCoord(long double jdf)
Computes the J2000.0 catalogue coordinates for this SkyPoint using the epoch removing aberration,...
Definition skypoint.cpp:710
void Equatorial1950ToGalactic(dms &galLong, dms &galLat)
Computes galactic coordinates from equatorial coordinates referred to epoch 1950.
Definition skypoint.cpp:735
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:257
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
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:01:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.