1 package com.billkuker.rocketry.motorsim.grain;
\r
3 import java.awt.Shape;
\r
4 import java.awt.geom.Ellipse2D;
\r
5 import java.awt.geom.Rectangle2D;
\r
6 import java.beans.PropertyVetoException;
\r
8 import javax.measure.quantity.Length;
\r
9 import javax.measure.unit.SI;
\r
11 import org.jscience.physics.amount.Amount;
\r
13 import com.billkuker.rocketry.motorsim.Validating;
\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 CSlot extends ExtrudedShapeGrain implements Validating {
\r
21 private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);
\r
22 private Amount<Length> iD = Amount.valueOf(0, SI.MILLIMETER);
\r
23 private Amount<Length> slotWidth = Amount.valueOf(5, SI.MILLIMETER);
\r
24 private Amount<Length> slotDepth = Amount.valueOf(15, SI.MILLIMETER);
\r
28 setLength(Amount.valueOf(70, SI.MILLIMETER));
\r
29 } catch (PropertyVetoException e) {
\r
30 e.printStackTrace();
\r
35 public Amount<Length> getOD() {
\r
39 public void setOD(Amount<Length> od) throws PropertyVetoException {
\r
44 public Amount<Length> getSlotWidth() {
\r
48 public void setSlotWidth(Amount<Length> slotWidth) {
\r
49 this.slotWidth = slotWidth;
\r
53 public Amount<Length> getSlotDepth() {
\r
57 public void setSlotDepth(Amount<Length> slotDepth) {
\r
58 this.slotDepth = slotDepth;
\r
65 private void generateGeometry() {
\r
66 double odmm = oD.doubleValue(SI.MILLIMETER);
\r
67 double wmm = slotWidth.doubleValue(SI.MILLIMETER);
\r
68 double dmm = slotDepth.doubleValue(SI.MILLIMETER);
\r
69 xsection = new BurningShape();
\r
70 Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);
\r
71 xsection.add(outside);
\r
72 xsection.inhibit(outside);
\r
74 double ymm = odmm/2.0 - wmm/2.0; //The Y position of the slot
\r
75 double xmm = odmm - dmm;
\r
76 Rectangle2D.Double slot;
\r
77 slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm);
\r
78 xsection.subtract(slot);
\r
80 double idmm = iD.doubleValue(SI.MILLIMETER);
\r
81 double idymm = odmm/2.0 - idmm/2.0;
\r
82 double idxmm = xmm - idmm/2.0;
\r
83 Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm);
\r
84 xsection.subtract(id);
\r
86 webThickness = null;
\r
89 public Amount<Length> getID() {
\r
93 public void setID(Amount<Length> id) {
\r
98 public static void main(String args[]) throws Exception {
\r
99 CSlot e = new CSlot();
\r
100 new Editor(e).showAsWindow();
\r
101 new GrainPanel(e).showAsWindow();
\r
104 public void validate() throws ValidationException{
\r
105 if ( oD.equals(Amount.ZERO) )
\r
106 throw new ValidationException(this, "Invalid oD");
\r
107 if ( getLength().equals(Amount.ZERO) )
\r
108 throw new ValidationException(this, "Invalid Length");
\r