package com.billkuker.rocketry.motorsim.visual.openRocket;\r
+\r
import java.util.List;\r
import java.util.Vector;\r
\r
import javax.measure.quantity.Duration;\r
+import javax.measure.quantity.Mass;\r
import javax.measure.unit.SI;\r
\r
import net.sf.openrocket.database.MotorDatabase;\r
\r
@Override\r
public String getDescription() {\r
- if ( burn == null )\r
+ if (burn == null)\r
return "NO MOTOR YET";\r
return burn.getMotor().getName();\r
}\r
cg = new Coordinate[burn.getData().size()];\r
time = new double[burn.getData().size()];\r
thrust = new double[burn.getData().size()];\r
- \r
\r
- for (int i = 0; i < cg.length; i++) {\r
- cg[i] = new Coordinate();\r
- cg[i].setWeight(0.0); //TODO: Set weight!\r
+ cg[0] = new Coordinate();\r
+ \r
+ double lastWeight = b\r
+ .getMotor()\r
+ .getGrain()\r
+ .volume(Amount.valueOf(0, SI.METER))\r
+ .times(b.getMotor().getFuel().getIdealDensity()\r
+ .times(b.getMotor().getFuel().getDensityRatio()))\r
+ .to(Mass.UNIT).doubleValue(SI.KILOGRAM);\r
+ \r
+ int i = 0;\r
+ double len = ((ICylindricalChamber) burn.getMotor().getChamber())\r
+ .getLength().doubleValue(SI.METER);\r
+ \r
+ for (Interval d : burn.getData().values()) {\r
+ lastWeight = lastWeight - d.fuelBurnt.doubleValue(SI.KILOGRAM);\r
+ cg[i] = new Coordinate(len/2.0,0,0,lastWeight);\r
+ System.err.println(lastWeight);\r
+ i++;\r
}\r
\r
- int i = 0;\r
+ i = 0;\r
for (Amount<Duration> t : burn.getData().keySet()) {\r
time[i++] = t.doubleValue(SI.SECOND);\r
}\r