1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.util.Coordinate;
4 import net.sf.openrocket.util.MathUtil;
6 public class EllipticalFinSet extends FinSet {
7 public static final int POINTS = 21;
9 private static final double[] POINT_X = new double[POINTS];
10 private static final double[] POINT_Y = new double[POINTS];
12 for (int i=0; i < POINTS; i++) {
13 double a = Math.PI * (POINTS-1-i)/(POINTS-1);
14 POINT_X[i] = (Math.cos(a)+1)/2;
15 POINT_Y[i] = Math.sin(a);
19 POINT_X[POINTS-1] = 1;
20 POINT_Y[POINTS-1] = 0;
24 private double height = 0.05;
26 public EllipticalFinSet() {
32 public Coordinate[] getFinPoints() {
33 Coordinate[] points = new Coordinate[POINTS];
34 for (int i=0; i < POINTS; i++) {
35 points[i] = new Coordinate(POINT_X[i]*length, POINT_Y[i]*height);
41 public double getSpan() {
46 public String getComponentName() {
47 return "Elliptical fin set";
51 public double getHeight() {
55 public void setHeight(double height) {
56 if (MathUtil.equals(this.height, height))
59 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
63 public void setLength(double length) {
64 if (MathUtil.equals(this.length, length))
67 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
72 * Accept a visitor to this EllipticalFinSet in the component hierarchy.
74 * @param theVisitor the visitor that will be called back with a reference to this EllipticalFinSet
77 public void accept(ComponentVisitor theVisitor) {
78 theVisitor.visit(this);