\r
private Amount<Length> oD, iD;\r
private boolean outerSurfaceInhibited = true, innerSurfaceInhibited = false;\r
+ \r
+ public static CoredCylindricalGrain DEFAULT_GRAIN = new CoredCylindricalGrain(){\r
+ {\r
+ try{\r
+ setOD(Amount.valueOf(30, SI.MILLIMETER));\r
+ setID(Amount.valueOf(10, SI.MILLIMETER));\r
+ setLength(Amount.valueOf(70, SI.MILLIMETER));\r
+ setInnerSurfaceInhibited(false);\r
+ setOuterSurfaceInhibited(true);\r
+ setForeEndInhibited(false);\r
+ setAftEndInhibited(false);\r
+ } catch ( Exception e ){\r
+ throw new Error(e);\r
+ }\r
+ }\r
+ };\r
\r
public CoredCylindricalGrain() {\r
-\r
oD = Amount.valueOf(30, SI.MILLIMETER);\r
iD = Amount.valueOf(10, SI.MILLIMETER);\r
}\r
}\r
\r
public static void main(String args[]) throws Exception {\r
- CoredCylindricalGrain e = new CoredCylindricalGrain();\r
+ CoredCylindricalGrain e = DEFAULT_GRAIN;\r
new Editor(e).show();\r
new GrainPanel(e).show();\r
}\r
\r
- \r
-\r
}\r
import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
\r
public class ExtrudedShapeGrain extends MotorPart implements Grain {\r
+ \r
+ public static ExtrudedShapeGrain DEFAULT_GRAIN = new ExtrudedShapeGrain(){\r
+ {\r
+ try{\r
+ Shape outside = new Ellipse2D.Double(0, 0, 30, 30);\r
+ xsection.add(outside);\r
+ xsection.inhibit(outside);\r
+ xsection.subtract(new Ellipse2D.Double(10,10, 10, 10));\r
+ setLength(Amount.valueOf(70, SI.MILLIMETER));\r
+ setEndSurfaceInhibited(false);\r
+ } catch ( Exception e ){\r
+ throw new Error(e);\r
+ }\r
+ }\r
+ };\r
\r
BurningShape xsection = new BurningShape();\r
\r
\r
Amount<Length> webThickness;\r
\r
- {\r
- /*\r
- * Similar test grain Shape outside = new Ellipse2D.Double(50,50,30,30);\r
- * plus.add(outside); minus.add(new Ellipse2D.Double(50,60,10,10));\r
- * inhibited.add(outside); length = Amount.valueOf(70, SI.MILLIMETER); /\r
- */\r
-\r
- /* Big c-slot */\r
- Shape outside = new Ellipse2D.Double(0, 0, 30, 30);\r
- xsection.add(outside);\r
- xsection.inhibit(outside);\r
- //xsection.subtract(new Rectangle2D.Double(13, 13, 4, 30));\r
- xsection.subtract(new Ellipse2D.Double(10,10, 10, 10));\r
- length = Amount.valueOf(100, SI.MILLIMETER);\r
- /**/\r
-\r
- /*\r
- * Plus sign Shape outside = new Ellipse2D.Double(0,0,200,200);\r
- * plus.add(outside); inhibited.add(outside); minus.add(new\r
- * Rectangle2D.Double(90,40,20,120)); minus.add(new\r
- * Rectangle2D.Double(40,90,120,20));\r
- */\r
-\r
- findWebThickness();\r
-\r
- }\r
-\r
@Override\r
public Amount<Area> surfaceArea(Amount<Length> regression) {\r
Amount<Area> zero = Amount.valueOf(0, Area.UNIT);\r
\r
@Override\r
public Amount<Length> webThickness() {\r
- return webThickness;\r
- }\r
-\r
- private void findWebThickness() {\r
+ if ( webThickness != null )\r
+ return webThickness;\r
java.awt.geom.Area a = getCrossSection(Amount.valueOf(0, SI.MILLIMETER));\r
Rectangle r = a.getBounds();\r
double max = r.getWidth() < r.getHeight() ? r.getHeight() : r\r
webThickness = Amount.valueOf(guess, SI.MILLIMETER);\r
if (webThickness.isGreaterThan(length.divide(2)))\r
webThickness = length.divide(2);\r
+ return webThickness;\r
}\r
\r
@Override\r
}\r
return res;\r
}\r
- \r
- public static void main(String args[]) throws Exception {\r
- ExtrudedShapeGrain e = new ExtrudedShapeGrain();\r
- new Editor(e).show();\r
- new GrainPanel(e).show();\r
- }\r
-\r
\r
public Amount<Length> getLength() {\r
return length;\r
firePropertyChange("endSurfaceInhibited", old, endSurfaceInhibited);\r
}\r
\r
+ \r
+ public static void main(String args[]) throws Exception {\r
+ ExtrudedShapeGrain e = DEFAULT_GRAIN;\r
+ new Editor(e).show();\r
+ new GrainPanel(e).show();\r
+ }\r
+\r
}\r
public class RodAndTubeGrain extends CompoundGrain {\r
CoredCylindricalGrain rod, tube;\r
\r
+ public static RodAndTubeGrain DEFAULT_GRAIN = new RodAndTubeGrain(){\r
+ {\r
+ try{\r
+ setOd(Amount.valueOf(30, SI.MILLIMETER));\r
+ setTubeID(Amount.valueOf(20, SI.MILLIMETER));\r
+ setRodDiameter(Amount.valueOf(10, SI.MILLIMETER));\r
+ setForeEndInhibited(true);\r
+ setAftEndInhibited(true);\r
+ } catch ( Exception e ){\r
+ throw new Error(e);\r
+ }\r
+ }\r
+ };\r
+ \r
public RodAndTubeGrain() {\r
try{\r
rod = new CoredCylindricalGrain();\r
- rod.setInnerSurfaceInhibited(true);\r
rod.setID(Amount.valueOf(0, SI.MILLIMETER));\r
- rod.setOD(Amount.valueOf(10, SI.MILLIMETER));\r
+ rod.setInnerSurfaceInhibited(true);\r
rod.setOuterSurfaceInhibited(false);\r
- rod.setForeEndInhibited(true);\r
- rod.setAftEndInhibited(true);\r
\r
tube = new CoredCylindricalGrain();\r
tube.setInnerSurfaceInhibited(false);\r
- tube.setID(Amount.valueOf(20, SI.MILLIMETER));\r
- tube.setOD(Amount.valueOf(30, SI.MILLIMETER));\r
- tube.setForeEndInhibited(true);\r
- tube.setAftEndInhibited(true);\r
} catch ( PropertyVetoException v ){\r
v.printStackTrace();\r
//I know these values are OK\r
}\r
- \r
add(rod);\r
add(tube);\r
}\r
\r
\r
public static void main(String args[]) throws Exception {\r
- Grain g = new RodAndTubeGrain();\r
+ Grain g = DEFAULT_GRAIN;\r
new Editor(g).show();\r
new GrainPanel(g).show();\r
}\r
\r
private static Logger log = Logger.getLogger(RotatedShapeGrain.class);\r
\r
+ public static RotatedShapeGrain DEFAULT_GRAIN = new RotatedShapeGrain(){\r
+ {\r
+ try{\r
+ Shape outside = new Rectangle2D.Double(0,0,15,70);\r
+ shape.add( outside );\r
+ shape.inhibit( outside );\r
+ shape.subtract( new Rectangle2D.Double(0,0,5,70));\r
+ shape.subtract(new Rectangle2D.Double(0, -10, 15, 10));\r
+ shape.subtract(new Rectangle2D.Double(0, 70, 15, 10));\r
+ } catch ( Exception e ){\r
+ throw new Error(e);\r
+ }\r
+ }\r
+ };\r
+ \r
public enum Quality {\r
High()\r
{{\r
\r
Amount<Length> web = null;\r
\r
- {\r
- Shape outside = new Rectangle2D.Double(0,0,15,100);\r
- shape.add( outside );\r
- shape.inhibit( outside );\r
- shape.subtract( new Rectangle2D.Double(0,0,5,100));\r
- shape.subtract(new Rectangle2D.Double(0, -10, 15, 10));\r
- shape.subtract(new Rectangle2D.Double(0, 100, 15, 10));\r
- }\r
-\r
@Override\r
public Area getCrossSection(Amount<Length> regression) {\r
Area ret = new Area();\r
return web;\r
\r
}\r
- \r
\r
- public static void main(String args[]) throws Exception {\r
- RotatedShapeGrain e = new RotatedShapeGrain();\r
- new Editor(e).show();\r
- new GrainPanel(e).show();\r
- }\r
- \r
private Shape square(java.awt.geom.Area a) {\r
PathIterator i = a.getPathIterator(new AffineTransform(), quality.squareFlatteningError);\r
GeneralPath cur = new GeneralPath();\r
return len;\r
}\r
\r
+ \r
\r
+ public static void main(String args[]) throws Exception {\r
+ RotatedShapeGrain e = DEFAULT_GRAIN;\r
+ new Editor(e).show();\r
+ new GrainPanel(e).show();\r
+ }\r
+ \r
}\r