git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@136 180e2...
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / EllipticalFinSet.java
1 package net.sf.openrocket.rocketcomponent;
2
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;
7
8 public class EllipticalFinSet extends FinSet {
9         private static final Translator trans = Application.getTranslator();
10
11         public static final int POINTS = 21;
12
13         private static final double[] POINT_X = new double[POINTS];
14         private static final double[] POINT_Y = new double[POINTS];
15         static {
16                 for (int i=0; i < POINTS; i++) {
17                         double a = Math.PI * (POINTS-1-i)/(POINTS-1);
18                         POINT_X[i] = (Math.cos(a)+1)/2;
19                         POINT_Y[i] = Math.sin(a);
20                 }
21                 POINT_X[0] = 0;
22                 POINT_Y[0] = 0;
23                 POINT_X[POINTS-1] = 1;
24                 POINT_Y[POINTS-1] = 0;
25         }
26
27
28         private double height = 0.05;
29
30         public EllipticalFinSet() {
31                 this.length = 0.05;
32         }
33
34
35         @Override
36         public Coordinate[] getFinPoints() {
37                 Coordinate[] points = new Coordinate[POINTS];
38                 for (int i=0; i < POINTS; i++) {
39                         points[i] = new Coordinate(POINT_X[i]*length, POINT_Y[i]*height);
40                 }
41                 return points;
42         }
43
44         @Override
45         public double getSpan() {
46                 return height;
47         }
48
49         @Override
50         public String getComponentName() {
51                 //// Elliptical fin set
52                 return trans.get("EllipticalFinSet.Ellipticalfinset");
53         }
54
55
56         public double getHeight() {
57                 return height;
58         }
59
60         public void setHeight(double height) {
61                 if (MathUtil.equals(this.height, height))
62                         return;
63                 this.height = height;
64                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
65         }
66
67
68         public void setLength(double length) {
69                 if (MathUtil.equals(this.length, length))
70                         return;
71                 this.length = length;
72                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
73         }
74
75
76 }