FACT++  1.0
void eraPv2s ( double  pv[2][3],
double *  theta,
double *  phi,
double *  r,
double *  td,
double *  pd,
double *  rd 
)

Definition at line 3 of file pv2s.c.

Referenced by eraHfk5z(), eraPvstar(), and t_pv2s().

40 {
41  double x, y, z, xd, yd, zd, rxy2, rxy, r2, rtrue, rw, xyp;
42 
43 /* Components of position/velocity vector. */
44  x = pv[0][0];
45  y = pv[0][1];
46  z = pv[0][2];
47  xd = pv[1][0];
48  yd = pv[1][1];
49  zd = pv[1][2];
50 
51 /* Component of r in XY plane squared. */
52  rxy2 = x*x + y*y;
53 
54 /* Modulus squared. */
55  r2 = rxy2 + z*z;
56 
57 /* Modulus. */
58  rtrue = sqrt(r2);
59 
60 /* If null vector, move the origin along the direction of movement. */
61  rw = rtrue;
62  if (rtrue == 0.0) {
63  x = xd;
64  y = yd;
65  z = zd;
66  rxy2 = x*x + y*y;
67  r2 = rxy2 + z*z;
68  rw = sqrt(r2);
69  }
70 
71 /* Position and velocity in spherical coordinates. */
72  rxy = sqrt(rxy2);
73  xyp = x*xd + y*yd;
74  if (rxy2 != 0.0) {
75  *theta = atan2(y, x);
76  *phi = atan2(z, rxy);
77  *td = (x*yd - y*xd) / rxy2;
78  *pd = (zd*rxy2 - z*xyp) / (r2*rxy);
79  } else {
80  *theta = 0.0;
81  *phi = (z != 0.0) ? atan2(z, rxy) : 0.0;
82  *td = 0.0;
83  *pd = 0.0;
84  }
85  *r = rtrue;
86  *rd = (rw != 0.0) ? (xyp + z*zd) / rw : 0.0;
87 
88  return;
89 
90 }

+ Here is the caller graph for this function: