1 /*
2  *  This library is free software; you can redistribute it and/or
3  *  modify it under the terms of the GNU Lesser General Public
4  *  License as published by the Free Software Foundation; either
5  *  version 2 of the License, or (at your option) any later version.
6  *
7  *  This library is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  Lesser General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  *  Copyright (C) 2000 - 2005 Liam Girdwood
17  */
18 
19 #include <libnova/proper_motion.h>
20 #include <libnova/utility.h>
21 
22 /*
23 ** Proper Motion.
24 */
25 
26 /*! \fn void ln_get_equ_pm (struct ln_equ_posn * mean_position, struct ln_equ_posn * proper_motion, double JD, struct ln_equ_posn * position)
27 * \param mean_position Mean position of object.
28 * \param proper_motion Annual Proper motion of object.
29 * \param JD Julian Day.
30 * \param position Pointer to store new object position.
31 *
32 * Calculate a stars equatorial coordinates from it's mean coordinates (J2000.0)
33 * with the effects of proper motion for a given Julian Day.
34 */
35 /* Example 20.b pg 126
36 */
ln_get_equ_pm(struct ln_equ_posn * mean_position,struct ln_equ_posn * proper_motion,double JD,struct ln_equ_posn * position)37 void ln_get_equ_pm (struct ln_equ_posn * mean_position, struct ln_equ_posn * proper_motion, double JD, struct ln_equ_posn * position)
38 {
39 	ln_get_equ_pm_epoch (mean_position, proper_motion, JD, JD2000, position);
40 }
41 
42 /*! \fn void ln_get_equ_pm_epoch (struct ln_equ_posn * mean_position, struct ln_equ_posn * proper_motion, double JD, double epoch_JD, struct ln_equ_posn * position)
43 * \param mean_position Mean position of object.
44 * \param proper_motion Annual Proper motion of object.
45 * \param JD Julian Day.
46 * \param JD_epoch Mean position epoch in JD
47 * \param position Pointer to store new object position.
48 *
49 * Calculate a stars equatorial coordinates from it's mean coordinates and epoch
50 * with the effects of proper motion for a given Julian Day.
51 */
52 /* Example 20.b, pg 126
53 */
ln_get_equ_pm_epoch(struct ln_equ_posn * mean_position,struct ln_equ_posn * proper_motion,double JD,double epoch_JD,struct ln_equ_posn * position)54 void ln_get_equ_pm_epoch (struct ln_equ_posn * mean_position, struct ln_equ_posn * proper_motion, double JD, double epoch_JD, struct ln_equ_posn * position)
55 {
56 	long double T;
57 
58 	T = (JD - epoch_JD) / 365.25;
59 
60 	/* calc proper motion */
61 	position->ra = mean_position->ra + T * proper_motion->ra;
62 	position->dec = mean_position->dec + T * proper_motion->dec;
63 
64 	/* change to degrees */
65 	position->ra = ln_range_degrees (position->ra);
66 }
67