Initial commit
[debian/openrocket] / src / net / sf / openrocket / aerodynamics / AerodynamicForces.java
1 package net.sf.openrocket.aerodynamics;
2
3 import net.sf.openrocket.rocketcomponent.RocketComponent;
4 import net.sf.openrocket.util.Coordinate;
5
6 public class AerodynamicForces implements Cloneable {
7         
8         /** 
9          * The component this data is referring to.  Used in analysis methods.
10          * A total value is indicated by the component being the Rocket component. 
11          */
12         public RocketComponent component = null;
13         
14
15         /** CG and mass */
16         public Coordinate cg = null;
17
18         /** Longitudal moment of inertia with reference to the CG. */
19         public double longitudalInertia = Double.NaN;
20         
21         /** Rotational moment of inertia with reference to the CG. */
22         public double rotationalInertia = Double.NaN;
23         
24         
25
26         /** CP and CNa. */
27         public Coordinate cp = null;
28         
29         
30         /**
31          * Normal force coefficient derivative.  At values close to zero angle of attack
32          * this value may be poorly defined or NaN if the calculation method does not
33          * compute CNa directly.
34          */
35         public double CNa = Double.NaN;
36
37         
38         /** Normal force coefficient. */
39         public double CN = Double.NaN;
40
41         /** Pitching moment coefficient, relative to the coordinate origin. */
42         public double Cm = Double.NaN;
43         
44         /** Side force coefficient, Cy */
45         public double Cside = Double.NaN;
46         
47         /** Yaw moment coefficient, Cn, relative to the coordinate origin. */
48         public double Cyaw = Double.NaN;
49         
50         /** Roll moment coefficient, Cl, relative to the coordinate origin. */
51         public double Croll = Double.NaN;
52         
53         /** Roll moment damping coefficient */
54         public double CrollDamp = Double.NaN;
55         
56         /** Roll moment forcing coefficient */
57         public double CrollForce = Double.NaN;
58         
59
60         
61         /** Axial drag coefficient, CA */
62         public double Caxial = Double.NaN;
63         
64         /** Total drag force coefficient, parallel to the airflow. */
65         public double CD = Double.NaN;
66         
67         /** Drag coefficient due to fore pressure drag. */
68         public double pressureCD = Double.NaN;
69         
70         /** Drag coefficient due to base drag. */
71         public double baseCD = Double.NaN;
72         
73         /** Drag coefficient due to friction drag. */
74         public double frictionCD = Double.NaN;
75         
76         
77         public double pitchDampingMoment = Double.NaN;
78         public double yawDampingMoment = Double.NaN;
79         
80         
81         /**
82          * Reset all values to null/NaN.
83          */
84         public void reset() {
85                 component = null;
86                 cg = null;
87                 longitudalInertia = Double.NaN;
88                 rotationalInertia = Double.NaN;
89
90                 cp = null;
91                 CNa = Double.NaN;
92                 CN = Double.NaN;
93                 Cm = Double.NaN;
94                 Cside = Double.NaN;
95                 Cyaw = Double.NaN;
96                 Croll = Double.NaN;
97                 CrollDamp = Double.NaN;
98                 CrollForce = Double.NaN;
99                 Caxial = Double.NaN;
100                 CD = Double.NaN;
101                 pitchDampingMoment = Double.NaN;
102                 yawDampingMoment = Double.NaN;
103         }
104         
105         /**
106          * Zero all values to 0 / Coordinate.NUL.  Component is left as it was.
107          */
108         public void zero() {
109                 // component untouched
110                 cg = Coordinate.NUL;
111                 longitudalInertia = 0;
112                 rotationalInertia = 0;
113
114                 cp = Coordinate.NUL;
115                 CNa = 0;
116                 CN = 0;
117                 Cm = 0;
118                 Cside = 0;
119                 Cyaw = 0;
120                 Croll = 0;
121                 CrollDamp = 0;
122                 CrollForce = 0;
123                 Caxial = 0;
124                 CD = 0;
125                 pitchDampingMoment = 0;
126                 yawDampingMoment = 0;
127         }
128
129         
130         @Override
131         public AerodynamicForces clone() {
132                 try {
133                         return (AerodynamicForces)super.clone();
134                 } catch (CloneNotSupportedException e) {
135                         throw new RuntimeException("CloneNotSupportedException?!?");
136                 }
137         }
138         
139         @Override
140         public String toString() {
141                 String text="AerodynamicForces[";
142                 
143                 if (component != null)
144                         text += "component:" + component + ",";
145                 if (cg != null)
146                         text += "cg:" + cg + ",";
147                 if (cp != null)
148                         text += "cp:" + cp + ",";
149                 if (!Double.isNaN(longitudalInertia))
150                         text += "longIn:" + longitudalInertia + ",";
151                 if (!Double.isNaN(rotationalInertia))
152                         text += "rotIn:" + rotationalInertia + ",";
153                 
154                 if (!Double.isNaN(CNa))
155                         text += "CNa:" + CNa + ",";
156                 if (!Double.isNaN(CN))
157                         text += "CN:" + CN + ",";
158                 if (!Double.isNaN(Cm))
159                         text += "Cm:" + Cm + ",";
160                 
161                 if (!Double.isNaN(Cside))
162                         text += "Cside:" + Cside + ",";
163                 if (!Double.isNaN(Cyaw))
164                         text += "Cyaw:" + Cyaw + ",";
165                 
166                 if (!Double.isNaN(Croll))
167                         text += "Croll:" + Croll + ",";
168                 if (!Double.isNaN(Caxial))
169                         text += "Caxial:" + Caxial + ",";
170                 
171                 if (!Double.isNaN(CD))
172                         text += "CD:" + CD + ",";
173
174                 if (text.charAt(text.length()-1) == ',')
175                         text = text.substring(0, text.length()-1);
176                 
177                 text += "]";
178                 return text;
179         }
180 }