/// <summary> /// Orbit foo, this finds the nodes of two orbits /// </summary> /// <returns> /// The true anomaly of the ascending node(descing node is 180degrees off) /// </returns> /// <param name='orbit'> /// Orbit. /// </param> /// <param name='tgtorbit'> /// Target Orbit /// </param> public static double FindAN(this Orbit orbit, Orbit tgtorbit) { Vector3d normal = ARUtils.swapYZ(orbit.GetOrbitNormal()); Vector3d targetNormal = ARUtils.swapYZ(tgtorbit.GetOrbitNormal()); Vector3d vectorToAN = Vector3d.Cross(normal, targetNormal); Vector3d vectorToPe = ARUtils.swapYZ(orbit.eccVec); double angleFromPe = Vector3d.Angle(vectorToPe, vectorToAN); //If the AN is actually during the infalling part of the orbit then we need to add 180 to //angle from Pe to get the true anomaly. Test this by taking the the cross product of the //orbit normal and vector to the periapsis. This gives a vector that points to center of the //outgoing side of the orbit. If vectorToAN is more than 90 degrees from this vector, it occurs //during the infalling part of the orbit. if (Math.Abs(Vector3d.Angle(vectorToAN, Vector3d.Cross(vectorToPe, normal))) < 90) { return(angleFromPe); } else { return(360 - angleFromPe); } /* double rad = Math.PI/180; * double Lan1 = orbit.LAN; * double inc1 = orbit.inclination; * double Lan2 = tgtorbit.LAN; * double inc2 = tgtorbit.inclination; * * //see braeunig.us/space... cross product of two orbital planes gives the node location * var a = new Vector3d(Math.Sin(inc1*rad)*Math.Cos(Lan1*rad), Math.Sin(inc1*rad)*Math.Sin(Lan1*rad), * Math.Cos(inc1*rad)); * var b = new Vector3d(Math.Sin(inc2*rad)*Math.Cos(Lan2*rad), Math.Sin(inc2*rad)*Math.Sin(Lan2*rad), * Math.Cos(inc2*rad)); * var c = new Vector3d(0, 0, 0); * c = Vector3d.Cross(a, b); * var coord = new double[] {0, 0}; * coord = LatLonofVector(c); //get the coordinates lat/lon of the ascending node * double lat = coord[0]; * double lon = coord[1]; * * //go look at the diagrams at braeunig.us/space * double α = lon - Lan1; //its all greek to me * if (α < 0) α += 360; * double λ = Math.Atan(Math.Tan(α*rad)/Math.Cos(inc1*rad))/rad; * double x = 180 + (λ - orbit.argumentOfPeriapsis); * if (x > 360) return 360 - x; * else return x;*/ }