Initial commit
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / EllipticalFinSet.java
1 package net.sf.openrocket.rocketcomponent;
2
3 import net.sf.openrocket.util.Coordinate;
4 import net.sf.openrocket.util.MathUtil;
5
6 public class EllipticalFinSet extends FinSet {
7         public static final int POINTS = 21;
8         
9         private static final double[] POINT_X = new double[POINTS];
10         private static final double[] POINT_Y = new double[POINTS];
11         static {
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);
16                 }
17                 POINT_X[0] = 0;
18                 POINT_Y[0] = 0;
19                 POINT_X[POINTS-1] = 1;
20                 POINT_Y[POINTS-1] = 0;
21         }
22         
23         
24         private double height = 0.05;
25         
26         public EllipticalFinSet() {
27                 this.length = 0.05;
28         }
29
30         
31         @Override
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);
36                 }
37                 return points;
38         }
39
40         @Override
41         public double getSpan() {
42                 return height;
43         }
44
45         @Override
46         public String getComponentName() {
47                 return "Elliptical fin set";
48         }
49         
50         
51         public double getHeight() {
52                 return height;
53         }
54         
55         public void setHeight(double height) {
56                 if (MathUtil.equals(this.height, height))
57                         return;
58                 this.height = height;
59                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
60         }
61         
62         
63         public void setLength(double length) {
64                 if (MathUtil.equals(this.length, length))
65                         return;
66                 this.length = length;
67                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
68         }
69
70 }