003650e11603ae6bbc5ae8b88ce82785dfa61557
[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         /**
75          * Compute an analysis of the per-component CG's of the provided configuration.
76          * The returned map will contain an entry for each physical rocket component (not stages)
77          * with its corresponding (best-effort) CG.  Overriding of subcomponents is ignored.
78          * The CG of the entire configuration with motors is stored in the entry with the corresponding
79          * Rocket as the key.
80          * 
81          * @param configuration         the rocket configuration
82          * @param type                          the state of the motors (none, launch mass, burnout mass)
83          * @return                                      a map from each rocket component to its corresponding CG.
84          */
85         public Map<RocketComponent, Coordinate> getCGAnalysis(Configuration configuration, MassCalcType type);
86         
87
88 }