Added C-Slot
authorBill Kuker <bkuker@billkuker.com>
Tue, 8 Sep 2009 20:49:34 +0000 (20:49 +0000)
committerBill Kuker <bkuker@billkuker.com>
Tue, 8 Sep 2009 20:49:34 +0000 (20:49 +0000)
src/com/billkuker/rocketry/motorsim/grain/CSlot.java [new file with mode: 0644]
src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java

diff --git a/src/com/billkuker/rocketry/motorsim/grain/CSlot.java b/src/com/billkuker/rocketry/motorsim/grain/CSlot.java
new file mode 100644 (file)
index 0000000..aa9fd62
--- /dev/null
@@ -0,0 +1,111 @@
+package com.billkuker.rocketry.motorsim.grain;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.Ellipse2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyVetoException;\r
+\r
+import javax.measure.quantity.Length;\r
+import javax.measure.unit.SI;\r
+\r
+import org.jscience.physics.amount.Amount;\r
+\r
+import com.billkuker.rocketry.motorsim.Validating;\r
+import com.billkuker.rocketry.motorsim.grain.util.BurningShape;\r
+import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;\r
+import com.billkuker.rocketry.motorsim.visual.Editor;\r
+import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
+\r
+public class CSlot extends ExtrudedShapeGrain implements Validating {\r
+\r
+       private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);\r
+       private Amount<Length> iD = Amount.valueOf(0, SI.MILLIMETER);\r
+       private Amount<Length> slotWidth = Amount.valueOf(5, SI.MILLIMETER);\r
+       private Amount<Length> slotDepth = Amount.valueOf(15, SI.MILLIMETER);\r
+       \r
+       public CSlot(){\r
+               try {\r
+                       setLength(Amount.valueOf(70, SI.MILLIMETER));\r
+               } catch (PropertyVetoException e) {\r
+                       e.printStackTrace();\r
+               }\r
+               generateGeometry();\r
+       }\r
+\r
+       public Amount<Length> getOD() {\r
+               return oD;\r
+       }\r
+\r
+       public void setOD(Amount<Length> od) throws PropertyVetoException {\r
+               this.oD = od;\r
+               generateGeometry();\r
+       }\r
+       \r
+       public Amount<Length> getSlotWidth() {\r
+               return slotWidth;\r
+       }\r
+\r
+       public void setSlotWidth(Amount<Length> slotWidth) {\r
+               this.slotWidth = slotWidth;\r
+               generateGeometry();\r
+       }\r
+\r
+       public Amount<Length> getSlotDepth() {\r
+               return slotDepth;\r
+       }\r
+\r
+       public void setSlotDepth(Amount<Length> slotDepth) {\r
+               this.slotDepth = slotDepth;\r
+               generateGeometry();\r
+       }\r
+\r
+\r
+\r
+\r
+       private void generateGeometry() {\r
+               double odmm = oD.doubleValue(SI.MILLIMETER);\r
+               double wmm = slotWidth.doubleValue(SI.MILLIMETER);\r
+               double dmm = slotDepth.doubleValue(SI.MILLIMETER);\r
+               xsection = new BurningShape();\r
+               Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);\r
+               xsection.add(outside);\r
+               xsection.inhibit(outside);\r
+               \r
+               double ymm = odmm/2.0 - wmm/2.0; //The Y position of the slot\r
+               double xmm = odmm - dmm;\r
+               Rectangle2D.Double slot;\r
+               slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm);\r
+               xsection.subtract(slot);\r
+               \r
+               double idmm = iD.doubleValue(SI.MILLIMETER);\r
+               double idymm = odmm/2.0 - idmm/2.0;\r
+               double idxmm = xmm - idmm/2.0;\r
+               Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm);\r
+               xsection.subtract(id);\r
+               \r
+               webThickness = null;\r
+       }\r
+       \r
+       public Amount<Length> getID() {\r
+               return iD;\r
+       }\r
+\r
+       public void setID(Amount<Length> id) {\r
+               iD = id;\r
+               generateGeometry();\r
+       }\r
+\r
+       public static void main(String args[]) throws Exception {\r
+               CSlot e = new CSlot();\r
+               new Editor(e).showAsWindow();\r
+               new GrainPanel(e).showAsWindow();\r
+       }\r
+       \r
+       public void validate() throws ValidationException{\r
+               if ( oD.equals(Amount.ZERO) )\r
+                       throw new ValidationException(this, "Invalid oD");\r
+               if ( getLength().equals(Amount.ZERO) )\r
+                       throw new ValidationException(this, "Invalid Length");\r
+       }\r
+\r
+}\r
index e66ff57d0a7a18e2352254964dc4b94f6ab4c19d..58a086da61c4fc94c6fe7a83f6bf872143b0a307 100644 (file)
@@ -46,6 +46,7 @@ import com.billkuker.rocketry.motorsim.fuel.KNDX;
 import com.billkuker.rocketry.motorsim.fuel.KNER;\r
 import com.billkuker.rocketry.motorsim.fuel.KNSB;\r
 import com.billkuker.rocketry.motorsim.fuel.KNSU;\r
+import com.billkuker.rocketry.motorsim.grain.CSlot;\r
 import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain;\r
 import com.billkuker.rocketry.motorsim.grain.Finocyl;\r
 import com.billkuker.rocketry.motorsim.grain.Moonburner;\r
@@ -77,7 +78,7 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
 \r
        @SuppressWarnings("unchecked")\r
        private Class[] grainTypes = { CoredCylindricalGrain.class, Finocyl.class,\r
-                       Moonburner.class, RodAndTubeGrain.class };\r
+                       Moonburner.class, RodAndTubeGrain.class, CSlot.class };\r
 \r
        @SuppressWarnings("unchecked")\r
        private Class[] fuelTypes = { KNSB.class, KNSU.class, KNER.class,\r