\r
import org.jscience.physics.amount.Amount;\r
\r
+import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;\r
+\r
import com.billkuker.rocketry.motorsim.Grain;\r
import com.billkuker.rocketry.motorsim.MotorPart;\r
import com.billkuker.rocketry.motorsim.visual.Editor;\r
import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
\r
-public class ExtrudedShapeGrain extends MotorPart implements Grain {\r
+public class ExtrudedShapeGrain extends ExtrudedGrain {\r
\r
public static ExtrudedShapeGrain DEFAULT_GRAIN = new ExtrudedShapeGrain(){\r
{\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
+ setForeEndInhibited(false);\r
+ setAftEndInhibited(false);\r
} catch ( Exception e ){\r
throw new Error(e);\r
}\r
};\r
\r
protected BurningShape xsection = new BurningShape();\r
-\r
- Amount<Length> length = Amount.valueOf(25, SI.MILLIMETER);\r
\r
- boolean endSurfaceInhibited = false;\r
-\r
Amount<Length> rStep;\r
\r
Amount<Length> webThickness;\r
if (regression.isGreaterThan(webThickness()))\r
return zero;\r
\r
- Amount<Length> rLen = length;\r
- if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
- rLen = length.minus(regression.times(2));\r
+ Amount<Length> rLen = regressedLength(regression);\r
\r
if (rLen.isLessThan(Amount.valueOf(0, SI.MILLIMETER)))\r
return zero;\r
SI.MILLIMETER))));\r
\r
Amount<Area> xSection = ShapeUtil.area(xsection.getShape(regression));\r
+ \r
+ Amount<Area> sides = ShapeUtil.perimeter(burn).divide(2).times(rLen).to(Area.UNIT);\r
+ Amount<Area> ends = xSection.times(numberOfBurningEnds(regression));\r
+ \r
+ return sides.plus(ends);\r
\r
- return ShapeUtil.perimeter(burn).divide(2).times(rLen).plus(\r
- xSection.times(2)).to(Area.UNIT);\r
}\r
\r
public Amount<Volume> volume(Amount<Length> regression) {\r
Amount<Volume> zero = Amount.valueOf(0, Volume.UNIT);\r
\r
- Amount<Length> rLen = length;\r
- if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
- rLen = length.minus(regression.times(2));\r
+ Amount<Length> rLen = regressedLength(regression);\r
\r
if (rLen.isLessThan(Amount.valueOf(0, SI.MILLIMETER)))\r
return zero;\r
break;\r
}\r
webThickness = Amount.valueOf(guess, SI.MILLIMETER);\r
- if (webThickness.isGreaterThan(length.divide(2)))\r
- webThickness = length.divide(2);\r
+ \r
+ //TODO Need to check # of burning ends!\r
+ if (webThickness.isGreaterThan(getLength().divide(2)))\r
+ webThickness = getLength().divide(2);\r
+ \r
return webThickness;\r
}\r
\r
public java.awt.geom.Area getSideView(Amount<Length> regression) {\r
java.awt.geom.Area res = new java.awt.geom.Area();\r
\r
- Amount<Length> rLen = length;\r
- if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
- rLen = length.minus(regression.times(2));\r
+ Amount<Length> rLen = regressedLength(regression);\r
\r
double rLenmm = rLen.doubleValue(SI.MILLIMETER);\r
\r
+ //TODO Shift up or down based on burning ends\r
for( java.awt.geom.Area a : ShapeUtil.separate(getCrossSection(regression))){\r
Rectangle2D bounds = a.getBounds2D();\r
Rectangle2D side = new Rectangle2D.Double(bounds.getMinX(), -rLenmm/2.0, bounds.getWidth(), rLenmm);\r
}\r
return res;\r
}\r
-\r
- public Amount<Length> getLength() {\r
- return length;\r
- }\r
-\r
- public void setLength(Amount<Length> length) throws PropertyVetoException {\r
- fireVetoableChange("length", this.length, length);\r
- Amount<Length> old = this.length;\r
- this.length = length;\r
- firePropertyChange("length", old, length);\r
- }\r
-\r
- public boolean isEndSurfaceInhibited() {\r
- return endSurfaceInhibited;\r
- }\r
-\r
- public void setEndSurfaceInhibited(boolean endSurfaceInhibited) throws PropertyVetoException {\r
- fireVetoableChange("endSurfaceInhibited", this.endSurfaceInhibited, endSurfaceInhibited);\r
- boolean old = this.endSurfaceInhibited;\r
- this.endSurfaceInhibited = endSurfaceInhibited;\r
- firePropertyChange("endSurfaceInhibited", old, endSurfaceInhibited);\r
- }\r
-\r
\r
public static void main(String args[]) throws Exception {\r
ExtrudedShapeGrain e = DEFAULT_GRAIN;\r