public static Distance GreatCircleDistance(CoordGeo pt1, CoordGeo pt2) { double distance = Math.Acos((Math.Sin(pt1.LatRad) * Math.Sin(pt2.LatRad)) + (Math.Cos(pt1.LatRad) * Math.Cos(pt2.LatRad) * Math.Cos(pt2.LonRad - pt1.LonRad))); distance = distance * 3963.0; // Statute Miles distance = distance * 1.609344; // to Km Distance d = new Distance(distance, DistanceUnits.KILOMETERS); return d; }
private void MakeFootprint(DateTime atTime) { this._footPrint.Clear(); // Constants double Re = 6378.137; double TWOPI = Math.PI * 2.0; double Rs = Math.Sqrt((Math.Pow(this.GetPositionECI(0).getPos().X, 2.0) + Math.Pow(this.GetPositionECI(0).getPos().Y, 2.0) + Math.Pow(this.GetPositionECI(0).getPos().Z, 2.0))); double srad = Math.Acos(Re / Rs); double latTemp = this.GetPositionGeo(atTime).m_Lat; double lonTemp = this.GetPositionGeo(atTime).m_Lon; double cla = Math.Cos(latTemp); double sla = Math.Sin(latTemp); double clo = Math.Cos(lonTemp); double slo = Math.Sin(lonTemp); double sra = Math.Sin(srad); double cra = Math.Cos(srad); double angle = 0.0; double X, Y, Z, x, y, z, lat, lon, lon1, lon2; for (int i = 0; i < 73; i++) { angle = i * (TWOPI / 72.0); X = cra; Y = sra * Math.Sin(angle); Z = sra * Math.Cos(angle); x = (X * cla) - (Z * sla); y = Y; z = (X * sla) + (Z * cla); X = (x * clo) - (y * slo); Y = (x * slo) + (y * clo); Z = z; lon = Math.Atan2(Y, X); lon1 = this.FN_Atan(Y, X); lon2 = this.FN_Atan2(Y, X); lat = Math.Asin(Z); CoordGeo cg = new CoordGeo(lat, lon, 0); this._footPrint.Add(cg); if (i == 0) { this._footDiam = new Distance(Globals.GreatCircleDistance(this.Position, cg).Kilometers * 2.0, DistanceUnits.KILOMETERS); } } }
public CoordGeo(double lat, double lon, double alt) { m_Lat = lat; m_Lon = lon; m_Alt = new Distance(alt, DistanceUnits.KILOMETERS); }
private bool InitFromTime(DateTime utc) { utc = Globals.InsureUTC(utc); TimeSpan ts = utc - this.EpochUTC; double minutes = ts.TotalMinutes; Eci position = new Eci(); try { position = this._orbit.getPosition(minutes); } catch (Exception) { return false; } this._lat = new Angle(position.toGeo().LatDeg, AngleUnits.DEGREES); this._lon = new Angle(position.toGeo().LonDeg, AngleUnits.DEGREES); this._alt = position.toGeo().Altitude; Vector velVec = position.getVel(); this._velX = velVec.X; this._velY = velVec.Y; this._velZ = velVec.Z; this._vel = Math.Sqrt(Math.Pow(this._velX, 2.0) + Math.Pow(this._velY, 2.0) + Math.Pow(this._velZ, 2.0)); CoordTopo ct = this.Site.getLookAngle(position); this._az = new Angle(ct.Azimuth); this._el = new Angle(ct.Elevation); this._rg = new Distance(ct.Range, DistanceUnits.KILOMETERS); this._rr = ct.RangeRate; this.MakeFootprint(utc); return true; }
public double m_Lon; // Longitude, radians (negative west) #endregion Fields #region Constructors public CoordGeo() { m_Lat = 0.0; m_Lon = 0.0; m_Alt = new Distance(0.0); }