File: NormalGravity.cpp

package info (click to toggle)
geographiclib 1.37-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,688 kB
  • ctags: 4,871
  • sloc: cpp: 31,440; sh: 11,632; cs: 9,411; ansic: 1,428; java: 1,333; python: 1,131; makefile: 758; xml: 381; pascal: 30
file content (200 lines) | stat: -rw-r--r-- 6,817 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**
 * \file NETGeographicLib/NormalGravity.cpp
 * \brief Implementation for NETGeographicLib::NormalGravity class
 *
 * NETGeographicLib is copyright (c) Scott Heiman (2013)
 * GeographicLib is Copyright (c) Charles Karney (2010-2012)
 * <charles@karney.com> and licensed under the MIT/X11 License.
 * For more information, see
 * http://geographiclib.sourceforge.net/
 **********************************************************************/
#include "stdafx.h"
#include "GeographicLib/NormalGravity.hpp"
#include "NormalGravity.h"
#include "Geocentric.h"
#include "NETGeographicLib.h"

using namespace NETGeographicLib;

const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::NormalGravity";

//*****************************************************************************
NormalGravity::!NormalGravity(void)
{
    if ( m_pNormalGravity != NULL )
    {
        delete m_pNormalGravity;
        m_pNormalGravity = NULL;
    }
}

//*****************************************************************************
NormalGravity::NormalGravity(double a, double GM, double omega, double f, double J2)
{
    try
    {
        m_pNormalGravity = new GeographicLib::NormalGravity( a, GM, omega, f, J2 );
    }
    catch ( std::bad_alloc )
    {
        throw gcnew GeographicErr( BADALLOC );
    }
    catch ( const std::exception& err )
    {
        throw gcnew GeographicErr( err.what() );
    }
}

//*****************************************************************************
NormalGravity::NormalGravity(StandardModels model)
{
    try
    {
        m_pNormalGravity = model == StandardModels::WGS84 ?
            new GeographicLib::NormalGravity( GeographicLib::NormalGravity::WGS84() ) :
            new GeographicLib::NormalGravity( GeographicLib::NormalGravity::GRS80() );
    }
    catch ( std::bad_alloc )
    {
        throw gcnew GeographicErr( BADALLOC );
    }
}

//*****************************************************************************
NormalGravity::NormalGravity( const GeographicLib::NormalGravity& g)
{
    try
    {
        m_pNormalGravity = new GeographicLib::NormalGravity( g );
    }
    catch ( std::bad_alloc )
    {
        throw gcnew GeographicErr( BADALLOC );
    }
}

//*****************************************************************************
double NormalGravity::SurfaceGravity(double lat)
{
    return m_pNormalGravity->SurfaceGravity( lat );
}

//*****************************************************************************
double NormalGravity::Gravity(double lat, double h,
    [System::Runtime::InteropServices::Out] double% gammay,
    [System::Runtime::InteropServices::Out] double% gammaz)
{
    double ly, lz;
    double out = m_pNormalGravity->Gravity( lat, h, ly, lz );
    gammay = ly;
    gammaz = lz;
    return out;
}

//*****************************************************************************
double NormalGravity::U(double X, double Y, double Z,
                [System::Runtime::InteropServices::Out] double% gammaX,
                [System::Runtime::InteropServices::Out] double% gammaY,
                [System::Runtime::InteropServices::Out] double% gammaZ)
{
    double lx, ly, lz;
    double out = m_pNormalGravity->U( X, Y, Z, lx, ly, lz );
    gammaX = lx;
    gammaY = ly;
    gammaZ = lz;
    return out;
}

//*****************************************************************************
double NormalGravity::V0(double X, double Y, double Z,
                [System::Runtime::InteropServices::Out] double% GammaX,
                [System::Runtime::InteropServices::Out] double% GammaY,
                [System::Runtime::InteropServices::Out] double% GammaZ)
{
    double lx, ly, lz;
    double out = m_pNormalGravity->V0( X, Y, Z, lx, ly, lz );
    GammaX = lx;
    GammaY = ly;
    GammaZ = lz;
    return out;
}

//*****************************************************************************
double NormalGravity::Phi(double X, double Y,
    [System::Runtime::InteropServices::Out] double% fX,
    [System::Runtime::InteropServices::Out] double% fY)
{
    double lx, ly;
    double out = m_pNormalGravity->Phi( X, Y, lx, ly );
    fX = lx;
    fY = ly;
    return out;
}

//*****************************************************************************
Geocentric^ NormalGravity::Earth()
{
    return gcnew Geocentric( m_pNormalGravity->Earth() );
}

//*****************************************************************************
double NormalGravity::MajorRadius::get()
{ return m_pNormalGravity->MajorRadius(); }

//*****************************************************************************
double NormalGravity::MassConstant::get()
{ return m_pNormalGravity->MassConstant(); }

//*****************************************************************************
double NormalGravity::DynamicalFormFactor(int n)
{ return m_pNormalGravity->DynamicalFormFactor(n); }

//*****************************************************************************
double NormalGravity::AngularVelocity::get()
{ return m_pNormalGravity->AngularVelocity(); }

//*****************************************************************************
double NormalGravity::Flattening::get()
{ return m_pNormalGravity->Flattening(); }

//*****************************************************************************
double NormalGravity::EquatorialGravity::get()
{ return m_pNormalGravity->EquatorialGravity(); }

//*****************************************************************************
double NormalGravity::PolarGravity::get()
{ return m_pNormalGravity->PolarGravity(); }

//*****************************************************************************
double NormalGravity::GravityFlattening::get()
{ return m_pNormalGravity->GravityFlattening(); }

//*****************************************************************************
double NormalGravity::SurfacePotential::get()
{ return m_pNormalGravity->SurfacePotential(); }

//*****************************************************************************
NormalGravity^ NormalGravity::WGS84()
{
    return gcnew NormalGravity( StandardModels::WGS84 );
}

//*****************************************************************************
NormalGravity^ NormalGravity::GRS80()
{
    return gcnew NormalGravity( StandardModels::GRS80 );
}

//*****************************************************************************
double NormalGravity::J2ToFlattening(double a, double GM, double omega,
                                     double J2)
{
    return GeographicLib::NormalGravity::J2ToFlattening( a, GM, omega, J2);
}

//*****************************************************************************
double NormalGravity::FlatteningToJ2(double a, double GM, double omega,
                                     double f)
{
    return GeographicLib::NormalGravity::FlatteningToJ2( a, GM, omega, f);
}