import java.util.Random;
+import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.material.Material.Type;
import net.sf.openrocket.motor.Motor;
rocket.setRevision("Rocket revision " + key);
rocket.setName(key);
-
+
Stage stage = new Stage();
setBasics(stage);
rocket.addChild(stage);
-
+
NoseCone nose = new NoseCone();
setBasics(stage);
nose.setAftRadius(rnd(0.03));
nose.setType((Shape) randomEnum(Shape.class));
stage.addChild(nose);
-
+
Transition shoulder = new Transition();
setBasics(shoulder);
shoulder.setAftRadius(rnd(0.06));
shoulder.setType((Shape) randomEnum(Shape.class));
stage.addChild(shoulder);
-
+
BodyTube body = new BodyTube();
setBasics(body);
body.setThickness(rnd(0.002));
body.setOuterRadiusAutomatic(rnd.nextBoolean());
stage.addChild(body);
-
+
Transition boattail = new Transition();
setBasics(boattail);
boattail.setAftRadius(rnd(0.03));
boattail.setType((Shape) randomEnum(Shape.class));
stage.addChild(boattail);
-
+
MassComponent mass = new MassComponent();
setBasics(mass);
mass.setComponentMass(rnd(0.05));
mass.setRadius(rnd(0.05));
nose.addChild(mass);
-
-
-
+
+
+
return rocket;
}
ExternalComponent e = (ExternalComponent) c;
e.setFinish((Finish) randomEnum(Finish.class));
double d = rnd(100);
- e.setMaterial(Material.newUserMaterial(Type.BULK, "Testmat " + d, d));
+ e.setMaterial(Databases.findMaterial(Type.BULK, "Testmat " + d, d));
}
if (c instanceof InternalComponent) {
}
-
+
private double rnd(double scale) {
return (rnd.nextDouble() * 0.2 + 0.9) * scale;
}
}
-
-
-
+
+
+
public Rocket makeSmallFlyable() {
double noseconeLength = 0.10, noseconeRadius = 0.01;
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
int finCount = 3;
double finRootChord = 0.04, finTipChord = 0.05, finSweep = 0.01, finThickness = 0.003, finHeight = 0.03;
-
+
Rocket rocket;
Stage stage;
NoseCone nosecone;
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
-
+
// Stage construction
rocket.addChild(stage);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
rocket.addChild(stage);
rocket.setPerfectFinish(false);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
+
public static Rocket makeIsoHaisu() {
Rocket rocket;
Stage stage;
tube3.setOverrideMass(0.730);
stage.addChild(tube3);
-
+
LaunchLug lug = new LaunchLug();
tube1.addChild(lug);
coupler.setPositionValue(-0.14);
tube1.addChild(coupler);
-
+
// Parachute
MassComponent mass = new MassComponent(0.05, 0.05, 0.280);
mass.setRelativePosition(Position.TOP);
mass.setPositionValue(0.25);
tube1.addChild(mass);
-
+
auxfinset = new TrapezoidFinSet();
auxfinset.setName("CONTROL");
auxfinset.setFinCount(2);
auxfinset.setBaseRotation(Math.PI / 2);
tube1.addChild(auxfinset);
-
-
-
+
+
+
coupler = new TubeCoupler();
coupler.setOuterRadiusAutomatic(true);
coupler.setLength(0.28);
coupler.setOverrideMass(0.360);
tube2.addChild(coupler);
-
-
+
+
// Parachute
mass = new MassComponent(0.1, 0.05, 0.028);
mass.setRelativePosition(Position.TOP);
mass.setPositionValue(0.19);
tube2.addChild(mass);
-
-
+
+
InnerTube inner = new InnerTube();
inner.setOuterRadius(0.08 / 2);
inner.setInnerRadius(0.0762 / 2);
inner.setOverrideMass(0.388);
tube3.addChild(inner);
-
+
CenteringRing center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0.28);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
center.setPositionValue(0.83);
tube3.addChild(center);
-
-
-
-
+
+
+
+
finset = new TrapezoidFinSet();
finset.setRootChord(0.495);
finset.setTipChord(0.1);
finset.setBaseRotation(Math.PI / 2);
tube3.addChild(finset);
-
+
finset.setCantAngle(0 * Math.PI / 180);
System.err.println("Fin cant angle: " + (finset.getCantAngle() * 180 / Math.PI));
-
+
// Stage construction
rocket.addChild(stage);
rocket.setPerfectFinish(false);
-
-
+
+
String id = rocket.newMotorConfigurationID();
tube3.setMotorMount(true);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
-
+
+
}