1 package net.sf.openrocket.aerodynamics;
3 import net.sf.openrocket.rocketcomponent.RocketComponent;
4 import net.sf.openrocket.util.BugException;
5 import net.sf.openrocket.util.Coordinate;
6 import net.sf.openrocket.util.MathUtil;
7 import net.sf.openrocket.util.Monitorable;
9 public class AerodynamicForces implements Cloneable, Monitorable {
12 * The component this data is referring to. Used in analysis methods.
13 * A total value is indicated by the component being the Rocket component.
15 private RocketComponent component = null;
19 private Coordinate cp = null;
23 * Normal force coefficient derivative. At values close to zero angle of attack
24 * this value may be poorly defined or NaN if the calculation method does not
25 * compute CNa directly.
27 private double CNa = Double.NaN;
30 /** Normal force coefficient. */
31 private double CN = Double.NaN;
33 /** Pitching moment coefficient, relative to the coordinate origin. */
34 private double Cm = Double.NaN;
36 /** Side force coefficient, Cy */
37 private double Cside = Double.NaN;
39 /** Yaw moment coefficient, Cn, relative to the coordinate origin. */
40 private double Cyaw = Double.NaN;
42 /** Roll moment coefficient, Cl, relative to the coordinate origin. */
43 private double Croll = Double.NaN;
45 /** Roll moment damping coefficient */
46 private double CrollDamp = Double.NaN;
48 /** Roll moment forcing coefficient */
49 private double CrollForce = Double.NaN;
53 /** Axial drag coefficient, CA */
54 private double Caxial = Double.NaN;
56 /** Total drag force coefficient, parallel to the airflow. */
57 private double CD = Double.NaN;
59 /** Drag coefficient due to fore pressure drag. */
60 private double pressureCD = Double.NaN;
62 /** Drag coefficient due to base drag. */
63 private double baseCD = Double.NaN;
65 /** Drag coefficient due to friction drag. */
66 private double frictionCD = Double.NaN;
69 private double pitchDampingMoment = Double.NaN;
70 private double yawDampingMoment = Double.NaN;
72 private int modID = 0;
75 public void setComponent(RocketComponent component) {
76 this.component = component;
80 public RocketComponent getComponent() {
84 public void setCP(Coordinate cp) {
89 public Coordinate getCP() {
93 public void setCNa(double cNa) {
98 public double getCNa() {
102 public void setCN(double cN) {
107 public double getCN() {
111 public void setCm(double cm) {
116 public double getCm() {
120 public void setCside(double cside) {
125 public double getCside() {
129 public void setCyaw(double cyaw) {
134 public double getCyaw() {
138 public void setCroll(double croll) {
143 public double getCroll() {
147 public void setCrollDamp(double crollDamp) {
148 CrollDamp = crollDamp;
152 public double getCrollDamp() {
156 public void setCrollForce(double crollForce) {
157 CrollForce = crollForce;
161 public double getCrollForce() {
165 public void setCaxial(double caxial) {
170 public double getCaxial() {
174 public void setCD(double cD) {
179 public double getCD() {
183 public void setPressureCD(double pressureCD) {
184 this.pressureCD = pressureCD;
188 public double getPressureCD() {
192 public void setBaseCD(double baseCD) {
193 this.baseCD = baseCD;
197 public double getBaseCD() {
201 public void setFrictionCD(double frictionCD) {
202 this.frictionCD = frictionCD;
206 public double getFrictionCD() {
210 public void setPitchDampingMoment(double pitchDampingMoment) {
211 this.pitchDampingMoment = pitchDampingMoment;
215 public double getPitchDampingMoment() {
216 return pitchDampingMoment;
219 public void setYawDampingMoment(double yawDampingMoment) {
220 this.yawDampingMoment = yawDampingMoment;
224 public double getYawDampingMoment() {
225 return yawDampingMoment;
231 * Reset all values to null/NaN.
233 public void reset() {
240 setCside(Double.NaN);
242 setCroll(Double.NaN);
243 setCrollDamp(Double.NaN);
244 setCrollForce(Double.NaN);
245 setCaxial(Double.NaN);
247 setPitchDampingMoment(Double.NaN);
248 setYawDampingMoment(Double.NaN);
252 * Zero all values to 0 / Coordinate.NUL. Component is left as it was.
255 // component untouched
257 setCP(Coordinate.NUL);
268 setPitchDampingMoment(0);
269 setYawDampingMoment(0);
274 public AerodynamicForces clone() {
276 return (AerodynamicForces)super.clone();
277 } catch (CloneNotSupportedException e) {
278 throw new BugException("CloneNotSupportedException?!?");
284 public boolean equals(Object obj) {
287 if (!(obj instanceof AerodynamicForces))
289 AerodynamicForces other = (AerodynamicForces) obj;
291 return (MathUtil.equals(this.getCNa(), other.getCNa()) &&
292 MathUtil.equals(this.getCN(), other.getCN()) &&
293 MathUtil.equals(this.getCm(), other.getCm()) &&
294 MathUtil.equals(this.getCside(), other.getCside()) &&
295 MathUtil.equals(this.getCyaw(), other.getCyaw()) &&
296 MathUtil.equals(this.getCroll(), other.getCroll()) &&
297 MathUtil.equals(this.getCrollDamp(), other.getCrollDamp()) &&
298 MathUtil.equals(this.getCrollForce(), other.getCrollForce()) &&
299 MathUtil.equals(this.getCaxial(), other.getCaxial()) &&
300 MathUtil.equals(this.getCD(), other.getCD()) &&
301 MathUtil.equals(this.getPressureCD(), other.getPressureCD()) &&
302 MathUtil.equals(this.getBaseCD(), other.getBaseCD()) &&
303 MathUtil.equals(this.getFrictionCD(), other.getFrictionCD()) &&
304 MathUtil.equals(this.getPitchDampingMoment(), other.getPitchDampingMoment()) &&
305 MathUtil.equals(this.getYawDampingMoment(), other.getYawDampingMoment()) &&
306 this.getCP().equals(other.getCP()));
310 public int hashCode() {
311 return (int) (1000*(this.getCD()+this.getCaxial()+this.getCNa())) + this.getCP().hashCode();
316 public String toString() {
317 String text="AerodynamicForces[";
319 if (getComponent() != null)
320 text += "component:" + getComponent() + ",";
322 text += "cp:" + getCP() + ",";
324 if (!Double.isNaN(getCNa()))
325 text += "CNa:" + getCNa() + ",";
326 if (!Double.isNaN(getCN()))
327 text += "CN:" + getCN() + ",";
328 if (!Double.isNaN(getCm()))
329 text += "Cm:" + getCm() + ",";
331 if (!Double.isNaN(getCside()))
332 text += "Cside:" + getCside() + ",";
333 if (!Double.isNaN(getCyaw()))
334 text += "Cyaw:" + getCyaw() + ",";
336 if (!Double.isNaN(getCroll()))
337 text += "Croll:" + getCroll() + ",";
338 if (!Double.isNaN(getCaxial()))
339 text += "Caxial:" + getCaxial() + ",";
341 if (!Double.isNaN(getCD()))
342 text += "CD:" + getCD() + ",";
344 if (text.charAt(text.length()-1) == ',')
345 text = text.substring(0, text.length()-1);
352 public int getModID() {