1 package com.billkuker.rocketry.motorsim.grain;
\r
3 import java.awt.Shape;
\r
4 import java.awt.geom.Ellipse2D;
\r
5 import java.beans.PropertyVetoException;
\r
7 import javax.measure.quantity.Length;
\r
8 import javax.measure.unit.SI;
\r
10 import org.jscience.physics.amount.Amount;
\r
12 import com.billkuker.rocketry.motorsim.grain.util.BurningShape;
\r
13 import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;
\r
14 import com.billkuker.rocketry.motorsim.visual.Editor;
\r
15 import com.billkuker.rocketry.motorsim.visual.GrainPanel;
\r
17 public class Moonburner extends ExtrudedShapeGrain {
\r
19 private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);
\r
20 private Amount<Length> iD = Amount.valueOf(10, SI.MILLIMETER);
\r
21 private Amount<Length> coreOffset = Amount.valueOf(0, SI.MILLIMETER);
\r
23 public Moonburner(){
\r
25 setLength(Amount.valueOf(70, SI.MILLIMETER));
\r
26 } catch (PropertyVetoException e) {
\r
27 e.printStackTrace();
\r
32 public Amount<Length> getOD() {
\r
36 public void setOD(Amount<Length> od) throws PropertyVetoException {
\r
37 if (od.equals(this.oD))
\r
39 fireVetoableChange("od", this.oD, od);
\r
40 Amount<Length> old = this.oD;
\r
43 firePropertyChange("OD", old, oD);
\r
46 public Amount<Length> getID() {
\r
50 public void setID(Amount<Length> id) throws PropertyVetoException {
\r
51 if (id.equals(this.iD))
\r
53 fireVetoableChange("id", this.iD, id);
\r
54 Amount<Length> old = this.iD;
\r
57 firePropertyChange("ID", old, iD);
\r
60 public Amount<Length> getCoreOffset() {
\r
64 public void setCoreOffset(Amount<Length> coreOffset)
\r
65 throws PropertyVetoException {
\r
66 if (coreOffset.equals(this.coreOffset))
\r
68 fireVetoableChange("coreOffset", this.coreOffset, coreOffset);
\r
69 Amount<Length> old = this.coreOffset;
\r
70 this.coreOffset = coreOffset;
\r
72 firePropertyChange("coreOffset", old, this.coreOffset);
\r
75 private void generateGeometry() {
\r
76 double odmm = oD.doubleValue(SI.MILLIMETER);
\r
77 double idmm = iD.doubleValue(SI.MILLIMETER);
\r
78 double offmm = coreOffset.doubleValue(SI.MILLIMETER);
\r
79 xsection = new BurningShape();
\r
80 Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);
\r
81 xsection.add(outside);
\r
82 xsection.inhibit(outside);
\r
84 xsection.subtract(new Ellipse2D.Double(odmm/2 - idmm/2 + offmm, odmm/2 - idmm/2 + offmm, idmm, idmm));
\r
85 webThickness = null;
\r
88 public static void main(String args[]) throws Exception {
\r
89 Moonburner e = new Moonburner();
\r
90 new Editor(e).showAsWindow();
\r
91 new GrainPanel(e).showAsWindow();
\r