--- /dev/null
+package com.billkuker.rocketry.motorsim.grain;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.Area;\r
+import java.awt.geom.Ellipse2D;\r
+import java.awt.geom.GeneralPath;\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 Star extends ExtrudedShapeGrain implements Validating {\r
+ private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);\r
+ private Amount<Length> iD = Amount.valueOf(5, SI.MILLIMETER);\r
+ private Amount<Length> pD = Amount.valueOf(15, SI.MILLIMETER);\r
+ private int pointCount = 5;\r
+ \r
+ public Star(){\r
+ try {\r
+ setLength(Amount.valueOf(70, SI.MILLIMETER));\r
+ } catch (PropertyVetoException e) {\r
+ e.printStackTrace();\r
+ }\r
+ generateGeometry();\r
+ }\r
+ \r
+ private void generateGeometry(){\r
+ double odmm = oD.doubleValue(SI.MILLIMETER);\r
+ double idmm = iD.doubleValue(SI.MILLIMETER)/2.0;\r
+ double pdmm = pD.doubleValue(SI.MILLIMETER)/2.0;\r
+ \r
+ xsection = new BurningShape();\r
+ Shape outside = new Ellipse2D.Double(-odmm/2, -odmm/2, odmm, odmm);\r
+ xsection.add(outside);\r
+ xsection.inhibit(outside);\r
+ //xsection.subtract(new Ellipse2D.Double(-idmm/2, -idmm/2, idmm, idmm));\r
+ webThickness = null;\r
+ \r
+ GeneralPath p = new GeneralPath();\r
+ double theta = 0;\r
+ double dTheta = (2.0 * Math.PI) / ( pointCount * 2.0 );\r
+ p.moveTo(0, idmm);\r
+ for ( int i = 0; i < pointCount; i++ ){\r
+ theta += dTheta;\r
+ p.lineTo(pdmm*Math.sin(theta), pdmm*Math.cos(theta));\r
+ theta += dTheta;\r
+ p.lineTo(idmm*Math.sin(theta), idmm*Math.cos(theta));\r
+ }\r
+ p.closePath();\r
+ xsection.subtract(new Area(p));\r
+ }\r
+ \r
+ public Amount<Length> getOD() {\r
+ return oD;\r
+ }\r
+\r
+ public void setOD(Amount<Length> od) throws PropertyVetoException {\r
+ if (od.equals(this.oD))\r
+ return;\r
+ this.oD = od;\r
+ generateGeometry();\r
+ }\r
+\r
+ public Amount<Length> getID() {\r
+ return iD;\r
+ }\r
+\r
+ public void setID(Amount<Length> id) throws PropertyVetoException {\r
+ if (id.equals(this.iD))\r
+ return;\r
+ iD = id;\r
+ generateGeometry();\r
+ }\r
+ \r
+ public Amount<Length> getPointDiameter() {\r
+ return pD;\r
+ }\r
+\r
+ public void setPointDiameter(Amount<Length> pd) throws PropertyVetoException {\r
+ if (pd.equals(this.pD))\r
+ return;\r
+ pD = pd;\r
+ generateGeometry();\r
+ }\r
+ \r
+ public int getPointCount(){\r
+ return pointCount;\r
+ }\r
+ \r
+ public void setPointCount(final int points){\r
+ pointCount = points;\r
+ generateGeometry();\r
+ }\r
+ \r
+ \r
+ public static void main(String args[]) throws Exception {\r
+ Star e = new Star();\r
+ new Editor(e).showAsWindow();\r
+ new GrainPanel(e).showAsWindow();\r
+ }\r
+ \r
+ @Override\r
+ public void validate() throws ValidationException{\r
+ if ( iD.equals(Amount.ZERO) )\r
+ throw new ValidationException(this, "Invalid iD");\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
+ if ( iD.isGreaterThan(oD) )\r
+ throw new ValidationException(this, "iD > oD"); \r
+ }\r
+}\r
--- /dev/null
+<!--Begin motor PVC9 HTML export from MotorSim-->\r
+<table class='motor'><tr><th colspan='6' class='title'>PVC9</th></tr><tr class='summary'><th>Rating:</th><td>58% G-157</td><th>Total Impulse:</th><td>120 Ns</td><th>Specific Impulse:</th><td>126 s</td></tr><tr class='summary'><th>Max Thrust:</th><td>219 N</td><th>Average Thrust:</th><td>157 N</td><th>Max Pressure:</th><td>3.3 MPa</td></tr><tr><td colspan='6' class='thrust'><img src='http://chart.apis.google.com/chart?chxt=x,x,y,y,r,r&chs=640x240&cht=lxy&chco=3072F3&chds=0,0.86,0,219.04&chxr=0,0,0.86|2,0,219.04|4,0,49.24&chd=t:0,0,0.02,0.06,0.1,0.16,0.25,0.36,0.53,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.71,0.71,0.71,0.76,0.85,0.86|0,55.46,108.17,115.05,124.61,137.84,155.59,178,202.54,219.04,199.1,180.29,162.61,146.03,130.54,116.12,102.76,90.42,79.08,68.72,0.05,0,0&chxl=1:|s|3:|N|5:|lbf&chxp=1,50|3,50|5,50&chtt=Thrust' width='640' height='240' alt='Thrust' /></td></tr></table>
+<!--End motor PVC9-->\r