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

KDE's Doxygen guidelines are available online.