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;
6 import net.sf.openrocket.util.MathUtil;
8 public class EllipticalFinSet extends FinSet {
9 private static final Translator trans = Application.getTranslator();
11 private static final int POINTS = 31;
13 // Static positioning for the fin points
14 private static final double[] POINT_X = new double[POINTS];
15 private static final double[] POINT_Y = new double[POINTS];
17 for (int i = 0; i < POINTS; i++) {
18 double a = Math.PI * (POINTS - 1 - i) / (POINTS - 1);
19 POINT_X[i] = (Math.cos(a) + 1) / 2;
20 POINT_Y[i] = Math.sin(a);
24 POINT_X[POINTS - 1] = 1;
25 POINT_Y[POINTS - 1] = 0;
29 private double height = 0.05;
31 public EllipticalFinSet() {
37 public Coordinate[] getFinPoints() {
38 double len = MathUtil.max(length, 0.0001);
39 Coordinate[] points = new Coordinate[POINTS];
40 for (int i = 0; i < POINTS; i++) {
41 points[i] = new Coordinate(POINT_X[i] * len, POINT_Y[i] * height);
47 public double getSpan() {
52 public String getComponentName() {
53 //// Elliptical fin set
54 return trans.get("EllipticalFinSet.Ellipticalfinset");
58 public double getHeight() {
62 public void setHeight(double height) {
63 if (MathUtil.equals(this.height, height))
66 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
70 public void setLength(double length) {
71 if (MathUtil.equals(this.length, length))
74 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);