1 package com.billkuker.rocketry.motorsim.grain;
\r
3 import java.awt.Shape;
\r
4 import java.awt.geom.AffineTransform;
\r
5 import java.awt.geom.Ellipse2D;
\r
6 import java.awt.geom.Rectangle2D;
\r
7 import java.beans.PropertyVetoException;
\r
9 import javax.measure.quantity.Length;
\r
10 import javax.measure.unit.SI;
\r
12 import org.jscience.physics.amount.Amount;
\r
14 import com.billkuker.rocketry.motorsim.grain.util.BurningShape;
\r
15 import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;
\r
16 import com.billkuker.rocketry.motorsim.visual.Editor;
\r
17 import com.billkuker.rocketry.motorsim.visual.GrainPanel;
\r
19 public class Finocyl extends ExtrudedShapeGrain {
\r
20 private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);
\r
21 private Amount<Length> iD = Amount.valueOf(10, SI.MILLIMETER);
\r
22 private Amount<Length> finWidth = Amount.valueOf(2, SI.MILLIMETER);
\r
23 private Amount<Length> finDiameter = Amount.valueOf(20, SI.MILLIMETER);
\r
24 private int finCount = 5;
\r
28 setLength(Amount.valueOf(70, SI.MILLIMETER));
\r
29 } catch (PropertyVetoException e) {
\r
30 e.printStackTrace();
\r
35 private void generateGeometry(){
\r
36 double odmm = oD.doubleValue(SI.MILLIMETER);
\r
37 double idmm = iD.doubleValue(SI.MILLIMETER);
\r
38 double fwmm = finWidth.doubleValue(SI.MILLIMETER);
\r
39 double fdmm = finDiameter.doubleValue(SI.MILLIMETER);
\r
41 xsection = new BurningShape();
\r
42 Shape outside = new Ellipse2D.Double(-odmm/2, -odmm/2, odmm, odmm);
\r
43 xsection.add(outside);
\r
44 xsection.inhibit(outside);
\r
45 xsection.subtract(new Ellipse2D.Double(-idmm/2, -idmm/2, idmm, idmm));
\r
46 webThickness = null;
\r
48 for ( int i = 0; i < finCount; i++ ){
\r
49 Shape fin = new Rectangle2D.Double(-fwmm/2,0,fwmm,fdmm/2);
\r
50 xsection.subtract(fin, AffineTransform.getRotateInstance(i*(2.0*Math.PI/finCount)));
\r
54 public Amount<Length> getOD() {
\r
58 public void setOD(Amount<Length> od) throws PropertyVetoException {
\r
59 if (od.equals(this.oD))
\r
61 fireVetoableChange("od", this.oD, od);
\r
62 Amount<Length> old = this.oD;
\r
65 firePropertyChange("OD", old, oD);
\r
68 public Amount<Length> getID() {
\r
72 public void setID(Amount<Length> id) throws PropertyVetoException {
\r
73 if (id.equals(this.iD))
\r
75 fireVetoableChange("id", this.iD, id);
\r
76 Amount<Length> old = this.iD;
\r
79 firePropertyChange("ID", old, iD);
\r
82 public Amount<Length> getFinWidth() {
\r
86 public void setFinWidth(Amount<Length> finWidth) throws PropertyVetoException {
\r
87 if (finWidth.equals(this.finWidth))
\r
89 fireVetoableChange("finWidth", this.finWidth, finWidth);
\r
90 Amount<Length> old = this.finWidth;
\r
91 this.finWidth = finWidth;
\r
93 firePropertyChange("finWidth", old, finWidth);
\r
97 public Amount<Length> getFinDiameter() {
\r
101 public void setFinDiameter(Amount<Length> finDiameter) throws PropertyVetoException {
\r
102 if (finDiameter.equals(this.finDiameter))
\r
104 fireVetoableChange("finDiameter", this.finDiameter, finDiameter);
\r
105 Amount<Length> old = this.finDiameter;
\r
106 this.finDiameter = finDiameter;
\r
107 generateGeometry();
\r
108 firePropertyChange("finDiameter", old, finDiameter);
\r
112 public int getFinCount() {
\r
116 public void setFinCount(int finCount) throws PropertyVetoException {
\r
117 if (finCount==this.finCount)
\r
119 fireVetoableChange("finCount", this.finCount, finCount);
\r
120 int old = this.finCount;
\r
121 this.finCount = finCount;
\r
122 generateGeometry();
\r
123 firePropertyChange("finCount", old, finCount);
\r
126 public static void main(String args[]) throws Exception {
\r
127 Finocyl e = new Finocyl();
\r
128 new Editor(e).showAsWindow();
\r
129 new GrainPanel(e).showAsWindow();
\r