aboutsummaryrefslogtreecommitdiff
path: root/src/libcf/space_vel.c
blob: e4729616303cd830e4a2da3498454d79eacaadc0 (plain) (blame)
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
/*****************************************************************************
 *              Johns Hopkins University
 *              Center For Astrophysical Sciences
 *              FUSE
 *****************************************************************************
 *
 * Synopsis:    double space_vel(double *vel, double ra, double dec)
 *
 * Description: Computes the projection of the spacecraft orbital velocity 
 *		vector onto a unit vector in the direction ra, dec.
 *
 * Arguments:   double *vel           (km/s) 3-vector velocity of satellite
 *              double ra,dec         (deg) position of target
 *
 * Returns:     double                (km/s) velocity in direction of target
 *                    
 * History:     03/04/98  E. Murphy   Begin work.
 *              03/04/98  E. Murphy   Initial version working
 *              07/07/99  E. Murphy   Converted x,y,z and vx,vy,vz to pos,vel
 *              06/15/01  V. Dixon    Comment out calculation of r, not used.
 *              12/18/03  bjg         Change calfusettag.h to calfuse.h
 *		07/21/04  1.4  wvd    Delete defn of r, as it is not used.
 *		03/04/07  1.5  wvd    Rewrite program to compute dot product
 *				      of target and velocity vectors.
 *
 ****************************************************************************/
 
#include <math.h>
#include "calfuse.h"
 
double space_vel(double vel[3], double ra, double dec)
{

    double x, y, z, phi;

    ra  *= RADIAN;
    dec *= RADIAN;

    z = sin(dec);
    phi = cos(dec);
    y = phi * sin(ra);
    x = phi * cos(ra);

    return x*vel[0] + y*vel[1] + z*vel[2];

}