00001
00002
00003
00004
00005
00006 namespace NewGamePhysics.Physics
00007 {
00008 using System;
00009
00017 public class GravityEarthGrsModel
00018 {
00022 public static double a = 6378137.0;
00023
00028 public static double GM = 3986005.0e8;
00029
00034 public static double J2 = 108263.0e-8;
00035
00039 public static double omega = 7292115.0e-11;
00040
00044 public static double b = 6356752.3141;
00045
00049 public static double E = 521854.0097;
00050
00054 public static double c = 6399593.6259;
00055
00059 public static double e2 = 0.00669438002290;
00060
00064 public static double ep2 = 0.00673949677548;
00065
00069 public static double f = 1.0/298.257222101;
00070
00074 public static double U0 = 62636860.850;
00075
00079 public static double J4 = -0.00000237091222;
00080
00084 public static double J6 = 0.00000000608347;
00085
00089 public static double J8 = -0.00000000001427;
00090
00094 public static double m = 0.00344978600308;
00095
00099 public static double ya = 9.7803267715;
00100
00104 public static double yb = 9.8321863685;
00105
00116 public double Calculate(double latitude, double height)
00117 {
00118 if ((latitude < -90.0) || (latitude > 90.0))
00119 {
00120 throw new ArgumentOutOfRangeException("latitude");
00121 }
00122
00123 if ((height < 0.0) || (height > 1000000.0))
00124 {
00125 throw new ArgumentOutOfRangeException("height");
00126 }
00127
00128
00129 double phi = Math.PI * latitude / 180.0;
00130 double sl = Math.Sin(phi);
00131 double s2l = Math.Sin(2.0 * phi);
00132 double sl2 = sl * sl;
00133 double s2l2 = s2l * s2l;
00134
00135
00136 double fs = (yb - ya) / ya;
00137 double f4 = -0.5 * f * f + 2.5 * f * m;
00138
00139
00140 double y = ya * (1.0 + fs * sl2 - 0.25 * f4 * s2l2);
00141
00142
00143 double yh = y * (1.0 - 2.0 / a * (1.0 + f + m - 2.0 * f * sl2) * height + 3.0 / (a * a) * (height * height));
00144
00145
00146 return yh;
00147 }
00148 }
00149 }