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
25 private Amount<Length> slotOffset = Amount.valueOf(0, SI.MILLIMETER);
\r
29 setLength(Amount.valueOf(70, SI.MILLIMETER));
\r
30 } catch (PropertyVetoException e) {
\r
31 e.printStackTrace();
\r
36 public Amount<Length> getOD() {
\r
40 public void setOD(Amount<Length> od) throws PropertyVetoException {
\r
45 public Amount<Length> getSlotWidth() {
\r
49 public void setSlotWidth(Amount<Length> slotWidth) {
\r
50 this.slotWidth = slotWidth;
\r
54 public Amount<Length> getSlotDepth() {
\r
58 public void setSlotDepth(Amount<Length> slotDepth) {
\r
59 this.slotDepth = slotDepth;
\r
63 public Amount<Length> getSlotOffset() {
\r
67 public void setSlotOffset(Amount<Length> slotOffset) {
\r
68 this.slotOffset = slotOffset;
\r
72 private void generateGeometry() {
\r
73 double odmm = oD.doubleValue(SI.MILLIMETER);
\r
74 double wmm = slotWidth.doubleValue(SI.MILLIMETER);
\r
75 double dmm = slotDepth.doubleValue(SI.MILLIMETER);
\r
76 xsection = new BurningShape();
\r
77 Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);
\r
78 xsection.add(outside);
\r
79 xsection.inhibit(outside);
\r
81 double offmm = slotOffset.doubleValue(SI.MILLIMETER);
\r
83 double ymm = odmm/2.0 - wmm/2.0 - offmm; //The Y position of the slot
\r
84 double xmm = odmm - dmm; //X pos of slot
\r
85 Rectangle2D.Double slot;
\r
86 slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm);
\r
87 xsection.subtract(slot);
\r
89 double idmm = iD.doubleValue(SI.MILLIMETER);
\r
90 double idymm = odmm/2.0 - idmm/2.0 - offmm; //y pos of id
\r
91 double idxmm = xmm - idmm/2.0; //x pos of id
\r
92 Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm);
\r
93 xsection.subtract(id);
\r
95 webThickness = null;
\r
98 public Amount<Length> getID() {
\r
102 public void setID(Amount<Length> id) {
\r
104 generateGeometry();
\r
107 public static void main(String args[]) throws Exception {
\r
108 CSlot e = new CSlot();
\r
109 new Editor(e).showAsWindow();
\r
110 new GrainPanel(e).showAsWindow();
\r
113 public void validate() throws ValidationException{
\r
114 if ( oD.equals(Amount.ZERO) )
\r
115 throw new ValidationException(this, "Invalid oD");
\r
116 if ( getLength().equals(Amount.ZERO) )
\r
117 throw new ValidationException(this, "Invalid Length");
\r