/* solve a spherical triangle: * A * / \ * / \ * c / \ b * / \ * / \ * B ____________ C * a * * given A, b, c find B and a in range 0..B..2PI and 0..a..PI, respectively.. * cap and Bp may be NULL if not interested in either one. * N.B. we pass in cos(c) and sin(c) because in many problems one of the sides * remains constant for many values of A and b. */ static void solve_sphere(double A, double b, double cc, double sc, ref double cap, ref double Bp) { double cb = Math.Cos(b), sb = Math.Sin(b); double sA, cA = Math.Cos(A); double x, y; double ca; double B; ca = cb * cc + sb * sc * cA; if (ca > 1.0) { ca = 1.0; } if (ca < -1.0) { ca = -1.0; } cap = ca; if (sc < 1e-7) { B = cc < 0 ? A : Math.PI - A; } else { sA = Math.Sin(A); y = sA * sb * sc; x = cb - ca * cc; B = Math.Atan2(y, x); } Bp = AstroConvert.Range2Pi(B); }
public static double FlipDecAxisRadians(double rad) { if (rad == 0.0) { return(rad); } bool isNegative = (rad < 0.0); double absRad = AstroConvert.Range2Pi(Math.Abs(rad)); // Converts to an absolute value from 0-360 double flippedValue = Constants.TWO_PI - absRad; if (isNegative) { flippedValue = flippedValue * -1.0; } return(flippedValue); }