1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.util.Coordinate;
6 * A set of trapezoidal fins. The root and tip chords are perpendicular to the rocket
7 * base line, while the leading and aft edges may be slanted.
9 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
12 public class TrapezoidFinSet extends FinSet {
13 public static final double MAX_SWEEP_ANGLE=(89*Math.PI/180.0);
22 * __________/________________|_____________
27 // rootChord == length
28 private double tipChord = 0;
29 private double height = 0;
30 private double sweep = 0;
33 public TrapezoidFinSet() {
34 this (3, 0.05, 0.05, 0.025, 0.05);
37 // TODO: HIGH: height=0 -> CP = NaN
38 public TrapezoidFinSet(int fins, double rootChord, double tipChord, double sweep,
42 this.setFinCount(fins);
43 this.length = rootChord;
44 this.tipChord = tipChord;
50 public void setFinShape(double rootChord, double tipChord, double sweep, double height,
52 if (this.length==rootChord && this.tipChord==tipChord && this.sweep==sweep &&
53 this.height==height && this.thickness==thickness)
55 this.length=rootChord;
56 this.tipChord=tipChord;
59 this.thickness=thickness;
60 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
63 public double getRootChord() {
66 public void setRootChord(double r) {
69 length = Math.max(r,0);
70 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
73 public double getTipChord() {
76 public void setTipChord(double r) {
79 tipChord = Math.max(r,0);
80 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
84 * Get the sweep length.
86 public double getSweep() {
90 * Set the sweep length.
92 public void setSweep(double r) {
96 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
100 * Get the sweep angle. This is calculated from the true sweep and height, and is not
103 public double getSweepAngle() {
111 return Math.atan(sweep/height);
114 * Sets the sweep by the sweep angle. The sweep is calculated and set by this method,
115 * and the angle itself is not stored.
117 public void setSweepAngle(double r) {
118 if (r > MAX_SWEEP_ANGLE)
120 if (r < -MAX_SWEEP_ANGLE)
121 r = -MAX_SWEEP_ANGLE;
122 double sweep = Math.tan(r) * height;
123 if (Double.isNaN(sweep) || Double.isInfinite(sweep))
128 public double getHeight() {
131 public void setHeight(double r) {
134 height = Math.max(r,0);
135 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
141 * Returns the geometry of a trapezoidal fin.
144 public Coordinate[] getFinPoints() {
145 Coordinate[] c = new Coordinate[4];
147 c[0] = Coordinate.NUL;
148 c[1] = new Coordinate(sweep,height);
149 c[2] = new Coordinate(sweep+tipChord,height);
150 c[3] = new Coordinate(length,0);
156 * Returns the span of a trapezoidal fin.
159 public double getSpan() {
165 public String getComponentName() {
166 return "Trapezoidal fin set";
170 * Accept a visitor to this TrapezoidFinSet in the component hierarchy.
172 * @param theVisitor the visitor that will be called back with a reference to this TrapezoidFinSet
175 public void accept(ComponentVisitor theVisitor) {
176 theVisitor.visit(this);