1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.l10n.Translator;
4 import net.sf.openrocket.startup.Application;
5 import net.sf.openrocket.util.Coordinate;
8 * A set of trapezoidal fins. The root and tip chords are perpendicular to the rocket
9 * base line, while the leading and aft edges may be slanted.
11 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
14 public class TrapezoidFinSet extends FinSet {
15 private static final Translator trans = Application.getTranslator();
17 public static final double MAX_SWEEP_ANGLE=(89*Math.PI/180.0);
26 * __________/________________|_____________
31 // rootChord == length
32 private double tipChord = 0;
33 private double height = 0;
34 private double sweep = 0;
37 public TrapezoidFinSet() {
38 this (3, 0.05, 0.05, 0.025, 0.05);
41 // TODO: HIGH: height=0 -> CP = NaN
42 public TrapezoidFinSet(int fins, double rootChord, double tipChord, double sweep,
46 this.setFinCount(fins);
47 this.length = rootChord;
48 this.tipChord = tipChord;
54 public void setFinShape(double rootChord, double tipChord, double sweep, double height,
56 if (this.length==rootChord && this.tipChord==tipChord && this.sweep==sweep &&
57 this.height==height && this.thickness==thickness)
59 this.length=rootChord;
60 this.tipChord=tipChord;
63 this.thickness=thickness;
64 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
67 public double getRootChord() {
70 public void setRootChord(double r) {
73 length = Math.max(r,0);
74 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
77 public double getTipChord() {
80 public void setTipChord(double r) {
83 tipChord = Math.max(r,0);
84 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
88 * Get the sweep length.
90 public double getSweep() {
94 * Set the sweep length.
96 public void setSweep(double r) {
100 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
104 * Get the sweep angle. This is calculated from the true sweep and height, and is not
107 public double getSweepAngle() {
115 return Math.atan(sweep/height);
118 * Sets the sweep by the sweep angle. The sweep is calculated and set by this method,
119 * and the angle itself is not stored.
121 public void setSweepAngle(double r) {
122 if (r > MAX_SWEEP_ANGLE)
124 if (r < -MAX_SWEEP_ANGLE)
125 r = -MAX_SWEEP_ANGLE;
126 double sweep = Math.tan(r) * height;
127 if (Double.isNaN(sweep) || Double.isInfinite(sweep))
132 public double getHeight() {
135 public void setHeight(double r) {
138 height = Math.max(r,0);
139 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
145 * Returns the geometry of a trapezoidal fin.
148 public Coordinate[] getFinPoints() {
149 Coordinate[] c = new Coordinate[4];
151 c[0] = Coordinate.NUL;
152 c[1] = new Coordinate(sweep,height);
153 c[2] = new Coordinate(sweep+tipChord,height);
154 c[3] = new Coordinate(length,0);
160 * Returns the span of a trapezoidal fin.
163 public double getSpan() {
169 public String getComponentName() {
170 //// Trapezoidal fin set
171 return trans.get("TrapezoidFinSet.TrapezoidFinSet");