~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to libsrc/astro/ast_ecl.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)ast_ecl.c        19.1 (ES0-DMD) 02/25/03 13:53:53 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
5
  This program is free software; you can redistribute it and/or 
 
6
  modify it under the terms of the GNU General Public License as 
 
7
  published by the Free Software Foundation; either version 2 of 
 
8
  the License, or (at your option) any later version.
 
9
 
 
10
  This program is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU General Public 
 
16
  License along with this program; if not, write to the Free 
 
17
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
  MA 02139, USA.
 
19
 
 
20
  Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
        Internet e-mail: midas@eso.org
 
22
        Postal address: European Southern Observatory
 
23
                        Data Management Division 
 
24
                        Karl-Schwarzschild-Strasse 2
 
25
                        D 85748 Garching bei Muenchen 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/*+++++++++++++++       
 
30
.TYPE           Module
 
31
.IDENTIFICATION ecl.c
 
32
.VERSION 1.0    05-Mar-1987: Creation .
 
33
.VERSION 1.1    24-Oct-1988: Application on Unit Vectors
 
34
.Language       C
 
35
.AUTHOR         Francois Ochsenbein [ESO-IPG]  
 
36
.KEYWORDS       Ecliptic / Equatorial Coordinate conversions
 
37
 
 
38
.COMMENTS
 
39
All spherical coordinates are assumed to be expressed in DEGREES.
 
40
 
 
41
\begin{TeX}
 
42
 
 
43
The parameter mnemonics are:
 
44
 
 
45
\begin{itemize}
 
46
 \item {\bf e} = array $[ x , y , z ]$    of  Ecliptic coordinates,
 
47
                in B1950 or J2000 frame
 
48
 \item {\bf f5} = array $[\alpha_{2000},\delta_{2000}]$ of Fundamental coordinates 
 
49
        at epoch J2000
 
50
 \item {\bf f} = array $[\alpha_{1950},\delta_{1950}]$ of eQuatorial coordinates 
 
51
        at epoch B1950.
 
52
\end{itemize}
 
53
 
 
54
 
 
55
The routines provided here only allows to compute ecliptic coordinates
 
56
from/to B1950 or J2000 epochs. If other epochs are required, the following
 
57
procedure can be used:
 
58
\begin{enumerate}
 
59
\item   Determine the rotation matrix $R$ from equatorial to ecliptic
 
60
        at epoch $t$ (in Julian Years) with {\tt ecl\_R}($t$, $R$).
 
61
\item   Rotate to ecliptic frame, using 
 
62
        {\tt tr\_oo}($q$, $e$, $R$).
 
63
\end{enumerate}
 
64
 
 
65
If a transformation from Ecliptic to Equatorial is wished, the only
 
66
modification is to replace the {\tt tr\_oo} function of step 2 by
 
67
the {\tt tr\_oo1} function (inverse rotation).
 
68
 
 
69
Reference: Murray, Vectorial Analysis, section 4.3; P.T. Wallace, Starlink.
 
70
\end{TeX}
 
71
 
 
72
-----------------------------------------------------------------------*/
 
73
 
 
74
#include <osdefos.h>
 
75
#include <astro.h>
 
76
#include <trigo.h>
 
77
#include <ok.h>
 
78
 
 
79
static double   RJ[3][3] = {    {1.e0, 0.e0, 0.e0},     /* Rotation in J2000 */
 
80
                        {0.e0, 1.e0, 0.e0},
 
81
                        {0.e0, 0.e0, 1.e0}};
 
82
static double  yj = -99999999.e0;
 
83
 
 
84
RGLOBAL double ecl_2000[3][3] = {               /* From J2000 => Ecl    */
 
85
  {1.0000000000000000, 0.0000000000000000, 0.0000000000000000}, 
 
86
  {0.0000000000000000, 0.9174820620691818, 0.3977771559319137},
 
87
  {0.0000000000000000,-0.3977771559319137, 0.9174820620691818}
 
88
  };
 
89
 
 
90
#define DEBUG           0       /* Debugging option     */
 
91
 
 
92
/*============================================================================*/
 
93
int ecl_R  (R, y)   
 
94
/*+++
 
95
.PURPOSE   Computation of Equatorial to Ecliptic rotation matrix
 
96
                at an epoch specified in Julian Years.
 
97
        The resulting matrix is such that
 
98
\begin{TeX}
 
99
\quad $\vec{u}_{ecl} = R \cdot \vec{u}_{eq}$ \quad (equatorial to ecliptic).
 
100
\end{TeX}
 
101
.RETURNS   OK
 
102
------------*/
 
103
        double y;       /* IN: Epoch, in Julian Years           */
 
104
        double R[3][3]; /* OUT: rotation matrix */
 
105
{
 
106
        double eps, dt;
 
107
 
 
108
  dt = (y-2000.e0)/100.e0;              /* In centuries         */
 
109
 
 
110
  eps = (84381.448e0 + (-46.8150e0 + (-0.00059e0+0.001813e0*dt)*dt)*dt)
 
111
        /3600.e0;                       /* Mean obliquity       */
 
112
 
 
113
        /* Compute Matrix (rotation around x-axis       */
 
114
 
 
115
      R[0][0] = 1.e0;
 
116
      R[0][1] = 0.e0;
 
117
      R[0][2] = 0.e0;
 
118
      R[1][0] = 0.e0;
 
119
      R[2][0] = 0.e0;
 
120
      R[1][1] = cosd(eps);
 
121
      R[1][2] = sind(eps);
 
122
      R[2][1] = -R[1][2];
 
123
      R[2][2] =  R[1][1];
 
124
 
 
125
  return(OK);
 
126
}
 
127
 
 
128
/*============================================================================
 
129
 *                      Transformations on Unit Vector
 
130
 *============================================================================*/
 
131
 
 
132
/*============================================================================*/
 
133
int tr_ef (e , f , y)  
 
134
/*+++
 
135
.PURPOSE Transformation from Ecliptic to eQuatorial.
 
136
.RETURNS OK
 
137
.REMARKS Same equinox for input and output coordinates.
 
138
---*/
 
139
        double e[2];    /* IN: Ecliptic angles at epoch y (degrees)     */
 
140
        double f[3];    /* OUT: Position in Frame at equinox y          */
 
141
        double y;       /* IN: Date for Ecliptic (Julian Years)         */
 
142
 
143
  if (y != yj)          /* Compute Rotation Matrix      */
 
144
        yj = y, ecl_R( RJ, yj);
 
145
 
 
146
  return (tr_uu1 ( e, f, RJ));
 
147
}
 
148
 
 
149
/*============================================================================*/
 
150
int tr_fe (f , e , y)  
 
151
/*+++
 
152
.PURPOSE Transformation from eQuatorial (B1950) to B1950 Ecliptic.
 
153
.RETURNS OK
 
154
.REMARKS Same equinox for input and output coordinates.
 
155
---*/
 
156
        double f[3];    /* IN: Vector in Equatorial frame       */
 
157
        double e[3];    /* OUT: Position in Ecliptic Frame, epoch y     */
 
158
        double y;       /* IN: Date for Ecliptic (Julain Years)         */
 
159
 
160
  if (y != yj)          /* Compute Rotation Matrix      */
 
161
        yj = y, ecl_R( RJ, yj);
 
162
 
 
163
  return (tr_uu ( f, e, RJ));
 
164
}
 
165