1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.material.Material;
4 import net.sf.openrocket.util.MathUtil;
5 import net.sf.openrocket.util.Prefs;
7 public class Parachute extends RecoveryDevice {
9 public static final double DEFAULT_CD = 0.8;
11 private double diameter;
13 private Material lineMaterial;
14 private int lineCount = 6;
15 private double lineLength = 0.3;
20 this.lineMaterial = Prefs.getDefaultComponentMaterial(Parachute.class, Material.Type.LINE);
21 this.lineLength = 0.3;
25 public double getDiameter() {
29 public void setDiameter(double d) {
30 if (MathUtil.equals(this.diameter, d))
33 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
37 public final Material getLineMaterial() {
41 public final void setLineMaterial(Material mat) {
42 if (mat.getType() != Material.Type.LINE) {
43 throw new IllegalArgumentException("Attempted to set non-line material " + mat);
45 if (mat.equals(lineMaterial))
47 this.lineMaterial = mat;
48 if (getLineCount() != 0)
49 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
51 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
55 public final int getLineCount() {
59 public final void setLineCount(int n) {
60 if (this.lineCount == n)
63 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
66 public final double getLineLength() {
70 public final void setLineLength(double length) {
71 if (MathUtil.equals(this.lineLength, length))
73 this.lineLength = length;
74 if (getLineCount() != 0)
75 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
77 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
82 public double getComponentCD(double mach) {
83 return DEFAULT_CD; // TODO: HIGH: Better parachute CD estimate?
87 public double getArea() {
88 return Math.PI * MathUtil.pow2(diameter / 2);
91 public void setArea(double area) {
92 if (MathUtil.equals(getArea(), area))
94 diameter = Math.sqrt(area / Math.PI) * 2;
95 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
99 public double getComponentMass() {
100 return super.getComponentMass() +
101 getLineCount() * getLineLength() * getLineMaterial().getDensity();
105 public String getComponentName() {
110 public boolean allowsChildren() {
115 public boolean isCompatible(Class<? extends RocketComponent> type) {