]> git.mxchange.org Git - flightgear.git/blob - LaRCsim/ls_gravity.c
Minor tweaks and fixes for cygwin32.
[flightgear.git] / 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  1997/05/29 00:09:56  curt
39 Initial Flight Gear revision.
40
41  * Revision 1.2  1994/01/11  18:50:35  bjax
42  * Corrected include files (was ls_eom.h) and DATA types changed
43  * to SCALARs. EBJ
44  *
45  * Revision 1.1  1992/12/30  13:18:46  bjax
46  * Initial revision
47  *              
48
49 ----------------------------------------------------------------------------
50
51                 REFERENCES:     Stevens, Brian L.; and Lewis, Frank L.: "Aircraft 
52                                 Control and Simulation", Wiley and Sons, 1992.
53                                 ISBN 0-471-
54
55 ----------------------------------------------------------------------------
56
57                 CALLED BY:
58
59 ----------------------------------------------------------------------------
60
61                 CALLS TO:
62
63 ----------------------------------------------------------------------------
64
65                 INPUTS:
66
67 ----------------------------------------------------------------------------
68
69                 OUTPUTS:
70
71 --------------------------------------------------------------------------*/
72 #include "ls_types.h"
73 #include "ls_constants.h"
74 #include <math.h>
75
76 #define GM      1.4076431E16
77 #define J2      1.08263E-3
78
79 void ls_gravity( SCALAR radius, SCALAR lat, SCALAR *gravity )
80 {
81
82         SCALAR  radius_ratio, rrsq, sinsqlat;
83         
84         radius_ratio = radius/EQUATORIAL_RADIUS;
85         rrsq = radius_ratio*radius_ratio;
86         sinsqlat = sin(lat)*sin(lat);
87         *gravity = (GM/(radius*radius))
88                 *sqrt(2.25*rrsq*rrsq*J2*J2*(5*sinsqlat*sinsqlat -2*sinsqlat + 1)
89                                 + 3*rrsq*J2*(1 - 3*sinsqlat) + 1);
90
91 }