1 package net.sf.openrocket.util;
3 import net.sf.openrocket.database.Databases;
4 import net.sf.openrocket.material.Material;
5 import net.sf.openrocket.rocketcomponent.BodyTube;
6 import net.sf.openrocket.rocketcomponent.Bulkhead;
7 import net.sf.openrocket.rocketcomponent.CenteringRing;
8 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
9 import net.sf.openrocket.rocketcomponent.InnerTube;
10 import net.sf.openrocket.rocketcomponent.LaunchLug;
11 import net.sf.openrocket.rocketcomponent.MassComponent;
12 import net.sf.openrocket.rocketcomponent.Motor;
13 import net.sf.openrocket.rocketcomponent.NoseCone;
14 import net.sf.openrocket.rocketcomponent.Rocket;
15 import net.sf.openrocket.rocketcomponent.Stage;
16 import net.sf.openrocket.rocketcomponent.Transition;
17 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
18 import net.sf.openrocket.rocketcomponent.TubeCoupler;
19 import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
20 import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
24 public static double noseconeLength=0.10,noseconeRadius=0.01;
25 public static double bodytubeLength=0.20,bodytubeRadius=0.01,bodytubeThickness=0.001;
27 public static int finCount=3;
28 public static double finRootChord=0.04,finTipChord=0.05,finSweep=0.01,finThickness=0.003, finHeight=0.03;
30 public static double materialDensity=1000; // kg/m3
33 public static Rocket makeRocket() {
37 BodyTube bodytube, bt2;
38 Transition transition;
39 TrapezoidFinSet finset;
41 rocket = new Rocket();
43 stage.setName("Stage1");
45 stage2.setName("Stage2");
46 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,noseconeLength,noseconeRadius);
47 bodytube = new BodyTube(bodytubeLength,bodytubeRadius,bodytubeThickness);
48 transition = new Transition();
49 bt2 = new BodyTube(bodytubeLength,bodytubeRadius*2,bodytubeThickness);
50 bt2.setMotorMount(true);
52 finset = new TrapezoidFinSet(finCount,finRootChord,finTipChord,finSweep,finHeight);
56 rocket.addChild(stage);
57 rocket.addChild(stage2);
60 // Component construction
61 stage.addChild(nosecone);
63 stage.addChild(bodytube);
66 stage2.addChild(transition);
70 bodytube.addChild(finset);
73 rocket.getDefaultConfiguration().setAllStages();
79 public static Rocket makeSmallFlyable() {
84 TrapezoidFinSet finset;
86 rocket = new Rocket();
88 stage.setName("Stage1");
90 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,noseconeLength,noseconeRadius);
91 bodytube = new BodyTube(bodytubeLength,bodytubeRadius,bodytubeThickness);
93 finset = new TrapezoidFinSet(finCount,finRootChord,finTipChord,finSweep,finHeight);
97 rocket.addChild(stage);
100 // Component construction
101 stage.addChild(nosecone);
102 stage.addChild(bodytube);
104 bodytube.addChild(finset);
106 Material material = Prefs.getDefaultComponentMaterial(null, Material.Type.BULK);
107 nosecone.setMaterial(material);
108 bodytube.setMaterial(material);
109 finset.setMaterial(material);
111 String id = rocket.newMotorConfigurationID();
112 bodytube.setMotorMount(true);
114 for (Motor m: Databases.MOTOR) {
115 if (m.getDesignation().equals("B4")) {
116 bodytube.setMotor(id, m);
120 bodytube.setMotorOverhang(0.005);
121 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
123 rocket.getDefaultConfiguration().setAllStages();
130 public static Rocket makeBigBlue() {
135 FreeformFinSet finset;
138 rocket = new Rocket();
140 stage.setName("Stage1");
142 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,0.105,0.033);
143 nosecone.setThickness(0.001);
144 bodytube = new BodyTube(0.69,0.033,0.001);
146 finset = new FreeformFinSet();
147 finset.setPoints(new Coordinate[] {
148 new Coordinate(0, 0),
149 new Coordinate(0.115, 0.072),
150 new Coordinate(0.255, 0.072),
151 new Coordinate(0.255, 0.037),
152 new Coordinate(0.150, 0)
154 finset.setThickness(0.003);
155 finset.setFinCount(4);
157 finset.setCantAngle(0*Math.PI/180);
158 System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
160 mcomp = new MassComponent(0.2,0.03,0.045 + 0.060);
161 mcomp.setRelativePosition(Position.TOP);
162 mcomp.setPositionValue(0);
164 // Stage construction
165 rocket.addChild(stage);
166 rocket.setPerfectFinish(false);
169 // Component construction
170 stage.addChild(nosecone);
171 stage.addChild(bodytube);
173 bodytube.addChild(finset);
175 bodytube.addChild(mcomp);
177 // Material material = new Material("Test material", 500);
178 // nosecone.setMaterial(material);
179 // bodytube.setMaterial(material);
180 // finset.setMaterial(material);
182 String id = rocket.newMotorConfigurationID();
183 bodytube.setMotorMount(true);
185 for (Motor m: Databases.MOTOR) {
186 if (m.getDesignation().equals("F12J")) {
187 bodytube.setMotor(id, m);
191 bodytube.setMotorOverhang(0.005);
192 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
194 rocket.getDefaultConfiguration().setAllStages();
202 public static Rocket makeIsoHaisu() {
206 BodyTube tube1, tube2, tube3;
207 TrapezoidFinSet finset;
208 TrapezoidFinSet auxfinset;
211 final double R = 0.07;
213 rocket = new Rocket();
215 stage.setName("Stage1");
217 nosecone = new NoseCone(Transition.Shape.OGIVE,0.53,R);
218 nosecone.setThickness(0.005);
219 nosecone.setMassOverridden(true);
220 nosecone.setOverrideMass(0.588);
221 stage.addChild(nosecone);
223 tube1 = new BodyTube(0.505,R,0.005);
224 tube1.setMassOverridden(true);
225 tube1.setOverrideMass(0.366);
226 stage.addChild(tube1);
228 tube2 = new BodyTube(0.605,R,0.005);
229 tube2.setMassOverridden(true);
230 tube2.setOverrideMass(0.427);
231 stage.addChild(tube2);
233 tube3 = new BodyTube(1.065,R,0.005);
234 tube3.setMassOverridden(true);
235 tube3.setOverrideMass(0.730);
236 stage.addChild(tube3);
239 LaunchLug lug = new LaunchLug();
242 TubeCoupler coupler = new TubeCoupler();
243 coupler.setOuterRadiusAutomatic(true);
244 coupler.setThickness(0.005);
245 coupler.setLength(0.28);
246 coupler.setMassOverridden(true);
247 coupler.setOverrideMass(0.360);
248 coupler.setRelativePosition(Position.BOTTOM);
249 coupler.setPositionValue(-0.14);
250 tube1.addChild(coupler);
254 MassComponent mass = new MassComponent(0.05, 0.05, 0.280);
255 mass.setRelativePosition(Position.TOP);
256 mass.setPositionValue(0.2);
257 tube1.addChild(mass);
260 mass = new MassComponent(0.05, 0.05, 0.125);
261 mass.setRelativePosition(Position.TOP);
262 mass.setPositionValue(0.2);
263 tube1.addChild(mass);
266 mass = new MassComponent(0.40, R, 1.500);
267 mass.setRelativePosition(Position.TOP);
268 mass.setPositionValue(0.25);
269 tube1.addChild(mass);
272 auxfinset = new TrapezoidFinSet();
273 auxfinset.setName("CONTROL");
274 auxfinset.setFinCount(2);
275 auxfinset.setRootChord(0.05);
276 auxfinset.setTipChord(0.05);
277 auxfinset.setHeight(0.10);
278 auxfinset.setSweep(0);
279 auxfinset.setThickness(0.008);
280 auxfinset.setCrossSection(CrossSection.AIRFOIL);
281 auxfinset.setRelativePosition(Position.TOP);
282 auxfinset.setPositionValue(0.28);
283 auxfinset.setBaseRotation(Math.PI/2);
284 tube1.addChild(auxfinset);
289 coupler = new TubeCoupler();
290 coupler.setOuterRadiusAutomatic(true);
291 coupler.setLength(0.28);
292 coupler.setRelativePosition(Position.TOP);
293 coupler.setPositionValue(0.47);
294 coupler.setMassOverridden(true);
295 coupler.setOverrideMass(0.360);
296 tube2.addChild(coupler);
301 mass = new MassComponent(0.1, 0.05, 0.028);
302 mass.setRelativePosition(Position.TOP);
303 mass.setPositionValue(0.14);
304 tube2.addChild(mass);
306 Bulkhead bulk = new Bulkhead();
307 bulk.setOuterRadiusAutomatic(true);
308 bulk.setMassOverridden(true);
309 bulk.setOverrideMass(0.050);
310 bulk.setRelativePosition(Position.TOP);
311 bulk.setPositionValue(0.27);
312 tube2.addChild(bulk);
315 mass = new MassComponent(0.1, 0.05, 0.125);
316 mass.setRelativePosition(Position.TOP);
317 mass.setPositionValue(0.19);
318 tube2.addChild(mass);
322 InnerTube inner = new InnerTube();
323 inner.setOuterRadius(0.08/2);
324 inner.setInnerRadius(0.0762/2);
325 inner.setLength(0.86);
326 inner.setMassOverridden(true);
327 inner.setOverrideMass(0.388);
328 tube3.addChild(inner);
331 CenteringRing center = new CenteringRing();
332 center.setInnerRadiusAutomatic(true);
333 center.setOuterRadiusAutomatic(true);
334 center.setLength(0.005);
335 center.setMassOverridden(true);
336 center.setOverrideMass(0.038);
337 center.setRelativePosition(Position.BOTTOM);
338 center.setPositionValue(0);
339 tube3.addChild(center);
342 center = new CenteringRing();
343 center.setInnerRadiusAutomatic(true);
344 center.setOuterRadiusAutomatic(true);
345 center.setLength(0.005);
346 center.setMassOverridden(true);
347 center.setOverrideMass(0.038);
348 center.setRelativePosition(Position.TOP);
349 center.setPositionValue(0.28);
350 tube3.addChild(center);
353 center = new CenteringRing();
354 center.setInnerRadiusAutomatic(true);
355 center.setOuterRadiusAutomatic(true);
356 center.setLength(0.005);
357 center.setMassOverridden(true);
358 center.setOverrideMass(0.038);
359 center.setRelativePosition(Position.TOP);
360 center.setPositionValue(0.83);
361 tube3.addChild(center);
367 finset = new TrapezoidFinSet();
368 finset.setRootChord(0.495);
369 finset.setTipChord(0.1);
370 finset.setHeight(0.185);
371 finset.setThickness(0.005);
372 finset.setSweep(0.3);
373 finset.setRelativePosition(Position.BOTTOM);
374 finset.setPositionValue(-0.03);
375 finset.setBaseRotation(Math.PI/2);
376 tube3.addChild(finset);
379 finset.setCantAngle(0*Math.PI/180);
380 System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
383 // Stage construction
384 rocket.addChild(stage);
385 rocket.setPerfectFinish(false);
389 String id = rocket.newMotorConfigurationID();
390 tube3.setMotorMount(true);
392 for (Motor m: Databases.MOTOR) {
393 if (m.getDesignation().equals("L540")) {
394 tube3.setMotor(id, m);
398 tube3.setMotorOverhang(0.02);
399 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
401 // tube3.setIgnitionEvent(MotorMount.IgnitionEvent.NEVER);
403 rocket.getDefaultConfiguration().setAllStages();