- Main Page
- Classes
- Files

- File List

# C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/Physics/GravityEarthWgsModel.cs

    00001 ﻿// --------------------------------------------------------
    00002 // GravityEarthWgsModel.cs
    00003 // (A. Schiffler, 2009)
    00004 // --------------------------------------------------------
    00005
    00006 namespace NewGamePhysics.Physics
    00007 {
    00008     using System;
    00009
    00017     public class GravityEarthWgsModel
    00018     {
    00022         public static double a = 6378137.0;
    00023
    00028         public static double GM = 3986004.418e8;
    00029
    00033         public static double omega = 7292115.0e-11;
    00034
    00038         public static double b = 6356752.3142;
    00039
    00043         public static double E = 5.2185400842339e5;
    00044
    00048         public static double c = 6399593.6258;
    00049
    00053         public static double e2 = 6.69437999014e-3;
    00054
    00058         public static double ep2 = 6.73949674228e-3;
    00059
    00063         public static double f = 1.0/298.257223563;
    00064
    00068         public static double U0 = 62636851.7146;
    00069
    00073         public static double m = 0.00344978650684;
    00074
    00078         public static double ya = 9.7803253359;
    00079
    00083         public static double yb = 9.8321849378;
    00084
    00088         public static double M = 5.9733328e24;
    00089
    00100         public double Calculate(double latitude, double height)
    00101         {
    00102             if ((latitude < -90.0) || (latitude > 90.0))
    00103             {
    00104                 throw new ArgumentOutOfRangeException("latitude");
    00105             }
    00106
    00107             if ((height < 0.0) || (height > 1000000.0))
    00108             {
    00109                 throw new ArgumentOutOfRangeException("height");
    00110             }
    00111
    00112             // precalculations
    00113             double phi = Math.PI * latitude / 180.0;
    00114             double sl = Math.Sin(phi);
    00115             double s2l = Math.Sin(2.0 * phi);
    00116             double sl2 = sl * sl;
    00117             double s2l2 = s2l * s2l;
    00118
    00119             // calculate gravity flattening
    00120             double fs = (yb - ya) / ya;
    00121             double f4 = -0.5 * f * f + 2.5 * f * m;
    00122
    00123             // calculate latitude dependent gravity
    00124             double y = ya * (1.0 + fs * sl2 - 0.25 * f4 * s2l2);
    00125
    00126             // calculate the height dependent gravity
    00127             double yh = y * (1.0 - 2.0 / a * (1.0 + f + m - 2.0 * f * sl2) * height + 3.0 / (a * a) * (height * height));
    00128
    00129             // result
    00130             return yh;
    00131         }
    00132     }
    00133 }