]> git.gag.com Git - debian/openrocket/blob - src/net/sf/openrocket/models/gravity/BasicGravityModel.java
7811227f6039a469aace194fef492b44cb1edc1d
[debian/openrocket] / src / net / sf / openrocket / models / gravity / BasicGravityModel.java
1 package net.sf.openrocket.models.gravity;
2
3 /**
4  * A gravity model based on the International Gravity Formula of 1967.  The gravity
5  * value is computed when the object is constructed and later returned as a static
6  * value.
7  * 
8  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
9  */
10 public class BasicGravityModel implements GravityModel {
11         
12         private final double g;
13         
14         /**
15          * Construct the static gravity model at the specific latitude (in degrees).
16          * @param latitude      the latitude in degrees (-90 ... 90)
17          */
18         public BasicGravityModel(double latitude) {
19                 double sin = Math.sin(latitude * Math.PI / 180);
20                 double sin2 = Math.sin(2 * latitude * Math.PI / 180);
21                 g = 9.780327 * (1 + 0.0053024 * sin - 0.0000058 * sin2);
22         }
23         
24         @Override
25         public double getGravity(double altitude) {
26                 return g;
27         }
28         
29         @Override
30         public int getModID() {
31                 // Return constant mod ID
32                 return (int) (g * 1000000);
33         }
34         
35 }