Re: SDP4 algorithm (part 2)

Rainer Kracht (R.Kracht@t-online.de)
Thu, 27 Mar 1997 21:17:22 +1

Just read Spacetrack Report No. 3 , p.69: "The function subroutine
ACTAN is passed the values of sine and cosine in that order and it
returns the angle in radians within the range of 0 to 2pi." That is
in the range of 0 to 360 deg, the same range as the RAAN has.

Quite obviously, the ACTAN function is not implemented in this way
in SGP_MATH.PAS of TS Kelso's Pascal Library:

Function AcTan(sinx,cosx : double) : double;
  begin
  if cosx = 0 then
    if sinx > 0 then
      Actan := pi/2
    else
      Actan := 3*pi/2
  else if cosx > 0 then
    Actan := ArcTan(sinx/cosx)
  else
    Actan := pi + ArcTan(sinx/cosx);
  end; {Function Actan}

This function will not work as intended with sinx < 0 and cosx > 0,
that is for angles in the range of 270 to 360 deg. These angles are
returned in the range of -90 to 0 deg.

I have changed Function AcTan to:

Function AcTan(sinx,cosx : double) : double;
  begin
  if cosx = 0 then
    if sinx > 0 then
      Actan := pi/2
    else
      Actan := 3*pi/2;
  if cosx > 0 then
    if sinx > 0 then
      Actan := ArcTan(sinx/cosx)
    else
      Actan := 2*pi + ArcTan(sinx/cosx);
  if cosx < 0 then
    Actan := pi + ArcTan(sinx/cosx);
  end; {Function Actan}

This function returns all angles in the range of 0 to 360 deg.

With this new function in use, it is no longer necessary to modify
DEEP.FOR or SGP4SDP4.PAS.

 Rainer