File: TelescopeDirectionVectorSupportFunctions.h

package info (click to toggle)
indi 2.1.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,888 kB
  • sloc: cpp: 217,447; ansic: 31,363; xml: 1,195; sh: 311; makefile: 13
file content (182 lines) | stat: -rw-r--r-- 10,169 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*!
 * \file TelescopeDirectionVectorSupportFunctions.h
 *
 * \author Roger James
 * \date 13th November 2013
 *
 */

#pragma once

#include "Common.h"
#include "libastro.h"
#include "indicom.h"

namespace INDI
{
namespace AlignmentSubsystem
{
/*! \class TelescopeDirectionVectorSupportFunctions
 *  \brief These functions are used to convert different coordinate systems to and from the
 *  telescope direction vectors (normalised vector/direction cosines) used for telescope coordinates in the
 *  alignment subsystem.
 */
class TelescopeDirectionVectorSupportFunctions
{
    public:
        /// \brief Virtual destructor
        virtual ~TelescopeDirectionVectorSupportFunctions() {}

        /*!
             * \enum AzimuthAngleDirection
             * The direction of measurement of an azimuth angle.
             * The following are the conventions for some coordinate systems.
             * - Right Ascension is measured ANTI_CLOCKWISE from the vernal equinox.
             * - Local Hour Angle is measured CLOCKWISE from the observer's meridian.
             * - Greenwich Hour Angle is measured CLOCKWISE from the Greenwich meridian.
             * - Azimuth (as in Altitude Azimuth coordinate systems ) is often measured CLOCKWISE\n
             * from north. But ESO FITS (Clockwise from South) and SDSS FITS(Anticlockwise from South)\n
             * have different conventions. Horizontal coordinates in libnova are measured clockwise from south.
             */
        typedef enum AzimuthAngleDirection
        {
            CLOCKWISE,     /*!< Angle is measured clockwise */
            ANTI_CLOCKWISE /*!< Angle is measured anti clockwise */
        } AzimuthAngleDirection_t;

        /*!
             * \enum PolarAngleDirection
             * The direction of measurement of a polar angle.
             * The following are conventions for some coordinate systems
             * - Declination is measured FROM_AZIMUTHAL_PLANE.
             * - Altitude is measured FROM_AZIMUTHAL_PLANE.
             * - Altitude in libnova horizontal coordinates is measured FROM_AZIMUTHAL_PLANE.
             */
        typedef enum PolarAngleDirection
        {
            FROM_POLAR_AXIS,     /*!< Angle is measured down from the polar axis */
            FROM_AZIMUTHAL_PLANE /*!< Angle is measured upwards from the azimuthal plane */
        } PolarAngleDirection_t;

        /*! \brief Calculates an altitude and azimuth from the supplied normalised direction vector
             * and declination.
             * \param[in] TelescopeDirectionVector
             * \param[out] HorizontalCoordinates Altitude and Azimuth in decimal degrees
             * \note This assumes a right handed coordinate system for the telescope direction vector with XY being the azimuthal plane,
             * and azimuth being measured in a clockwise direction.
             */
        void AltitudeAzimuthFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector,
                INDI::IHorizontalCoordinates &HorizontalCoordinates)
        {
            double AzimuthAngle;
            double AltitudeAngle;
            SphericalCoordinateFromTelescopeDirectionVector(TelescopeDirectionVector, AzimuthAngle, CLOCKWISE,
                    AltitudeAngle, FROM_AZIMUTHAL_PLANE);
            HorizontalCoordinates.azimuth  = range360(RAD_TO_DEG(AzimuthAngle));
            HorizontalCoordinates.altitude = RAD_TO_DEG(AltitudeAngle);
        };

        /*! \brief Calculates equatorial coordinates from the supplied telescope direction vector
             * and declination.
             * \param[in] TelescopeDirectionVector
             * \param[out] EquatorialCoordinates The equatorial coordinates in hours minutes seconds and degrees minutes seconds
             * \note This assumes a right handed coordinate system for the direction vector with the right ascension being in the XY plane.
             */
        void EquatorialCoordinatesFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector,
                INDI::IEquatorialCoordinates &EquatorialCoordinates)
        {
            double AzimuthAngle;
            double PolarAngle;
            SphericalCoordinateFromTelescopeDirectionVector(TelescopeDirectionVector, AzimuthAngle, ANTI_CLOCKWISE,
                    PolarAngle, FROM_AZIMUTHAL_PLANE);
            EquatorialCoordinates.rightascension  = range24(RAD_TO_DEG(AzimuthAngle) / 15.0);
            EquatorialCoordinates.declination = rangeDec(RAD_TO_DEG(PolarAngle));
        };

        /*! \brief Calculates a local hour angle and declination from the supplied telescope direction vector
             * and declination.
             * \param[in] TelescopeDirectionVector
             * \param[out] EquatorialCoordinates The local hour angle and declination in decimal degrees
             * \note This assumes a right handed coordinate system for the direction vector with the hour angle being in the XY plane.
             */
        void LocalHourAngleDeclinationFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector,
                INDI::IEquatorialCoordinates &EquatorialCoordinates)
        {
            double AzimuthAngle;
            double PolarAngle;
            SphericalCoordinateFromTelescopeDirectionVector(TelescopeDirectionVector, AzimuthAngle, CLOCKWISE, PolarAngle,
                    FROM_AZIMUTHAL_PLANE);
            EquatorialCoordinates.rightascension  = range24(RAD_TO_DEG(AzimuthAngle) / 15.0);
            EquatorialCoordinates.declination = rangeDec(RAD_TO_DEG(PolarAngle));
        };

        /*! \brief Calculates a spherical coordinate from the supplied telescope direction vector
             * \param[in] TelescopeDirectionVector
             * \param[out] AzimuthAngle The azimuth angle in radians
             * \param[in] AzimuthAngleDirection The direction the azimuth angle has been measured either CLOCKWISE or ANTI_CLOCKWISE
             * \param[out] PolarAngle The polar angle in radians
             * \param[in] PolarAngleDirection The direction the polar angle has been measured either FROM_POLAR_AXIS or FROM_AZIMUTHAL_PLANE
             * \note TelescopeDirectionVectors are always normalised and right handed.
             */
        void SphericalCoordinateFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector,
                double &AzimuthAngle,
                AzimuthAngleDirection_t AzimuthAngleDirection,
                double &PolarAngle, PolarAngleDirection_t PolarAngleDirection);

        /*! \brief Calculates a normalised direction vector from the supplied altitude and azimuth.
             * \param[in] HorizontalCoordinates Altitude and Azimuth in decimal degrees
             * \return A TelescopeDirectionVector
             * \note This assumes a right handed coordinate system for the telescope direction vector with XY being the azimuthal plane,
             * and azimuth being measured in a clockwise direction.
             */
        const TelescopeDirectionVector TelescopeDirectionVectorFromAltitudeAzimuth(INDI::IHorizontalCoordinates
                HorizontalCoordinates)
        {
            return TelescopeDirectionVectorFromSphericalCoordinate(DEG_TO_RAD(HorizontalCoordinates.azimuth), CLOCKWISE,
                    DEG_TO_RAD(HorizontalCoordinates.altitude),
                    FROM_AZIMUTHAL_PLANE);
        };

        /*! \brief Calculates a telescope direction vector from the supplied equatorial coordinates.
             * \param[in] EquatorialCoordinates The equatorial coordinates in hours minutes seconds and degrees minutes seconds
             * \return A TelescopeDirectionVector
             * \note This assumes a right handed coordinate system for the direction vector with the right ascension being in the XY plane.
             */
        const TelescopeDirectionVector
        TelescopeDirectionVectorFromEquatorialCoordinates(INDI::IEquatorialCoordinates EquatorialCoordinates)
        {
            return TelescopeDirectionVectorFromSphericalCoordinate(DEG_TO_RAD(EquatorialCoordinates.rightascension * 15.0),
                    ANTI_CLOCKWISE,
                    DEG_TO_RAD(EquatorialCoordinates.declination),
                    FROM_AZIMUTHAL_PLANE);
        };

        /*! \brief Calculates a telescope direction vector from the supplied local hour angle and declination.
             * \param[in] EquatorialCoordinates The local hour angle and declination in decimal degrees
             * \return A TelescopeDirectionVector
             * \note This assumes a right handed coordinate system for the direction vector with the hour angle being in the XY plane.
             */
        const TelescopeDirectionVector
        TelescopeDirectionVectorFromLocalHourAngleDeclination(INDI::IEquatorialCoordinates EquatorialCoordinates)
        {
            return TelescopeDirectionVectorFromSphericalCoordinate(DEG_TO_RAD(EquatorialCoordinates.rightascension * 15.0), CLOCKWISE,
                    DEG_TO_RAD(EquatorialCoordinates.declination),
                    FROM_AZIMUTHAL_PLANE);
        };

        /*! \brief Calculates a telescope direction vector from the supplied spherical coordinate information
             * \param[in] AzimuthAngle The azimuth angle in radians
             * \param[in] AzimuthAngleDirection The direction the azimuth angle has been measured either CLOCKWISE or ANTI_CLOCKWISE
             * \param[in] PolarAngle The polar angle in radians
             * \param[in] PolarAngleDirection The direction the polar angle has been measured either FROM_POLAR_AXIS or FROM_AZIMUTHAL_PLANE
             * \return A TelescopeDirectionVector
             * \note TelescopeDirectionVectors are always assumed to be normalised and right handed.
             */
        const TelescopeDirectionVector
        TelescopeDirectionVectorFromSphericalCoordinate(const double AzimuthAngle,
                AzimuthAngleDirection_t AzimuthAngleDirection,
                const double PolarAngle, PolarAngleDirection_t PolarAngleDirection);
};

} // namespace AlignmentSubsystem
} // namespace INDI