Added gravitational acceleration and propellant mass datatypes.
[debian/openrocket] / core / src / net / sf / openrocket / masscalc / MassCalculator.java
1 package net.sf.openrocket.masscalc;
2
3 import java.util.Map;
4
5 import net.sf.openrocket.motor.Motor;
6 import net.sf.openrocket.motor.MotorInstanceConfiguration;
7 import net.sf.openrocket.rocketcomponent.Configuration;
8 import net.sf.openrocket.rocketcomponent.RocketComponent;
9 import net.sf.openrocket.util.Coordinate;
10 import net.sf.openrocket.util.Monitorable;
11
12 public interface MassCalculator extends Monitorable {
13         
14         public static enum MassCalcType {
15                 NO_MOTORS {
16                         @Override
17                         public Coordinate getCG(Motor motor) {
18                                 return Coordinate.NUL;
19                         }
20                 },
21                 LAUNCH_MASS {
22                         @Override
23                         public Coordinate getCG(Motor motor) {
24                                 return motor.getLaunchCG();
25                         }
26                 },
27                 BURNOUT_MASS {
28                         @Override
29                         public Coordinate getCG(Motor motor) {
30                                 return motor.getEmptyCG();
31                         }
32                 };
33                 
34                 public abstract Coordinate getCG(Motor motor);
35         }
36         
37         /**
38          * Compute the CG of the provided configuration.
39          * 
40          * @param configuration         the rocket configuration
41          * @param type                          the state of the motors (none, launch mass, burnout mass)
42          * @return                                      the CG of the configuration
43          */
44         public Coordinate getCG(Configuration configuration, MassCalcType type);
45         
46         /**
47          * Compute the CG of the provided configuration with specified motors.
48          * 
49          * @param configuration         the rocket configuration
50          * @param motors                        the motor configuration
51          * @return                                      the CG of the configuration
52          */
53         public Coordinate getCG(Configuration configuration, MotorInstanceConfiguration motors);
54         
55         /**
56          * Compute the longitudinal inertia of the provided configuration with specified motors.
57          * 
58          * @param configuration         the rocket configuration
59          * @param motors                        the motor configuration
60          * @return                                      the longitudinal inertia of the configuration
61          */
62         public double getLongitudinalInertia(Configuration configuration, MotorInstanceConfiguration motors);
63         
64         /**
65          * Compute the rotational inertia of the provided configuration with specified motors.
66          * 
67          * @param configuration         the rocket configuration
68          * @param motors                        the motor configuration
69          * @return                                      the rotational inertia of the configuration
70          */
71         public double getRotationalInertia(Configuration configuration, MotorInstanceConfiguration motors);
72         
73         /**
74          * Return the total mass of the motors
75          * 
76          * @param motors                        the motor configuration
77          * @param configuration         the current motor instance configuration
78          * @return                                      the total mass of all motors
79          */
80         public double getPropellantMass(Configuration configuration, MotorInstanceConfiguration motors);        
81         
82         /**
83          * Compute an analysis of the per-component CG's of the provided configuration.
84          * The returned map will contain an entry for each physical rocket component (not stages)
85          * with its corresponding (best-effort) CG.  Overriding of subcomponents is ignored.
86          * The CG of the entire configuration with motors is stored in the entry with the corresponding
87          * Rocket as the key.
88          * 
89          * @param configuration         the rocket configuration
90          * @param type                          the state of the motors (none, launch mass, burnout mass)
91          * @return                                      a map from each rocket component to its corresponding CG.
92          */
93         public Map<RocketComponent, Coordinate> getCGAnalysis(Configuration configuration, MassCalcType type);
94         
95
96 }