create changelog entry
[debian/openrocket] / core / 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         private static final int POINTS = 31;
12         
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];
16         static {
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);
21                 }
22                 POINT_X[0] = 0;
23                 POINT_Y[0] = 0;
24                 POINT_X[POINTS - 1] = 1;
25                 POINT_Y[POINTS - 1] = 0;
26         }
27         
28
29         private double height = 0.05;
30         
31         public EllipticalFinSet() {
32                 this.length = 0.05;
33         }
34         
35         
36         @Override
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);
42                 }
43                 return points;
44         }
45         
46         @Override
47         public double getSpan() {
48                 return height;
49         }
50         
51         @Override
52         public String getComponentName() {
53                 //// Elliptical fin set
54                 return trans.get("EllipticalFinSet.Ellipticalfinset");
55         }
56         
57         
58         public double getHeight() {
59                 return height;
60         }
61         
62         public void setHeight(double height) {
63                 if (MathUtil.equals(this.height, height))
64                         return;
65                 this.height = height;
66                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
67         }
68         
69         
70         public void setLength(double length) {
71                 if (MathUtil.equals(this.length, length))
72                         return;
73                 this.length = length;
74                 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
75         }
76         
77
78 }