]> git.mxchange.org Git - flightgear.git/blob - src/FDM/LaRCsim/ls_gravity.c
Updates to the scenery loading infrastructure to make it more flexible,
[flightgear.git] / src / FDM / LaRCsim / ls_gravity.c
1 /***************************************************************************
2
3         TITLE:  ls_gravity
4                 
5 ----------------------------------------------------------------------------
6
7         FUNCTION:       Gravity model for LaRCsim
8
9 ----------------------------------------------------------------------------
10
11         MODULE STATUS:  developmental
12
13 ----------------------------------------------------------------------------
14
15         GENEALOGY:      Created by Bruce Jackson on September 25, 1992.
16
17 ----------------------------------------------------------------------------
18
19         DESIGNED BY:    Bruce Jackson
20                 
21         CODED BY:       Bruce Jackson
22                 
23         MAINTAINED BY:  Bruce Jackson
24
25 ----------------------------------------------------------------------------
26
27         MODIFICATION HISTORY:
28                 
29         DATE    PURPOSE                                                 BY
30                 
31         940111  Changed include files to "ls_types.h" and 
32                 "ls_constants.h" from "ls_eom.h"; also changed DATA types
33                 to SCALAR types.                                        EBJ
34                 
35                                                                                 
36 $Header$
37 $Log$
38 Revision 1.1  1999/06/17 18:07:34  curt
39 Initial revision
40
41 Revision 1.1.1.1  1999/04/05 21:32:45  curt
42 Start of 0.6.x branch.
43
44 Revision 1.3  1998/08/06 12:46:39  curt
45 Header change.
46
47 Revision 1.2  1998/01/19 18:40:26  curt
48 Tons of little changes to clean up the code and to remove fatal errors
49 when building with the c++ compiler.
50
51 Revision 1.1  1997/05/29 00:09:56  curt
52 Initial Flight Gear revision.
53
54  * Revision 1.2  1994/01/11  18:50:35  bjax
55  * Corrected include files (was ls_eom.h) and DATA types changed
56  * to SCALARs. EBJ
57  *
58  * Revision 1.1  1992/12/30  13:18:46  bjax
59  * Initial revision
60  *              
61
62 ----------------------------------------------------------------------------
63
64                 REFERENCES:     Stevens, Brian L.; and Lewis, Frank L.: "Aircraft 
65                                 Control and Simulation", Wiley and Sons, 1992.
66                                 ISBN 0-471-
67
68 ----------------------------------------------------------------------------
69
70                 CALLED BY:
71
72 ----------------------------------------------------------------------------
73
74                 CALLS TO:
75
76 ----------------------------------------------------------------------------
77
78                 INPUTS:
79
80 ----------------------------------------------------------------------------
81
82                 OUTPUTS:
83
84 --------------------------------------------------------------------------*/
85 #include "ls_types.h"
86 #include "ls_constants.h"
87 #include "ls_gravity.h"
88 #include <math.h>
89
90 #define GM      1.4076431E16
91 #define J2      1.08263E-3
92
93 void ls_gravity( SCALAR radius, SCALAR lat, SCALAR *gravity )
94 {
95
96         SCALAR  radius_ratio, rrsq, sinsqlat;
97         
98         radius_ratio = radius/EQUATORIAL_RADIUS;
99         rrsq = radius_ratio*radius_ratio;
100         sinsqlat = sin(lat)*sin(lat);
101         *gravity = (GM/(radius*radius))
102                 *sqrt(2.25*rrsq*rrsq*J2*J2*(5*sinsqlat*sinsqlat -2*sinsqlat + 1)
103                                 + 3*rrsq*J2*(1 - 3*sinsqlat) + 1);
104
105 }