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.motor.Motor;
6 import net.sf.openrocket.rocketcomponent.BodyTube;
7 import net.sf.openrocket.rocketcomponent.Bulkhead;
8 import net.sf.openrocket.rocketcomponent.CenteringRing;
9 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
10 import net.sf.openrocket.rocketcomponent.IllegalFinPointException;
11 import net.sf.openrocket.rocketcomponent.InnerTube;
12 import net.sf.openrocket.rocketcomponent.LaunchLug;
13 import net.sf.openrocket.rocketcomponent.MassComponent;
14 import net.sf.openrocket.rocketcomponent.NoseCone;
15 import net.sf.openrocket.rocketcomponent.Rocket;
16 import net.sf.openrocket.rocketcomponent.Stage;
17 import net.sf.openrocket.rocketcomponent.Transition;
18 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
19 import net.sf.openrocket.rocketcomponent.TubeCoupler;
20 import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
21 import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
25 public static double noseconeLength=0.10,noseconeRadius=0.01;
26 public static double bodytubeLength=0.20,bodytubeRadius=0.01,bodytubeThickness=0.001;
28 public static int finCount=3;
29 public static double finRootChord=0.04,finTipChord=0.05,finSweep=0.01,finThickness=0.003, finHeight=0.03;
31 public static double materialDensity=1000; // kg/m3
34 public static Rocket makeRocket() {
38 BodyTube bodytube, bt2;
39 Transition transition;
40 TrapezoidFinSet finset;
42 rocket = new Rocket();
44 stage.setName("Stage1");
46 stage2.setName("Stage2");
47 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,noseconeLength,noseconeRadius);
48 bodytube = new BodyTube(bodytubeLength,bodytubeRadius,bodytubeThickness);
49 transition = new Transition();
50 bt2 = new BodyTube(bodytubeLength,bodytubeRadius*2,bodytubeThickness);
51 bt2.setMotorMount(true);
53 finset = new TrapezoidFinSet(finCount,finRootChord,finTipChord,finSweep,finHeight);
57 rocket.addChild(stage);
58 rocket.addChild(stage2);
61 // Component construction
62 stage.addChild(nosecone);
64 stage.addChild(bodytube);
67 stage2.addChild(transition);
71 bodytube.addChild(finset);
74 rocket.getDefaultConfiguration().setAllStages();
80 public static Rocket makeSmallFlyable() {
85 TrapezoidFinSet finset;
87 rocket = new Rocket();
89 stage.setName("Stage1");
91 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,noseconeLength,noseconeRadius);
92 bodytube = new BodyTube(bodytubeLength,bodytubeRadius,bodytubeThickness);
94 finset = new TrapezoidFinSet(finCount,finRootChord,finTipChord,finSweep,finHeight);
98 rocket.addChild(stage);
101 // Component construction
102 stage.addChild(nosecone);
103 stage.addChild(bodytube);
105 bodytube.addChild(finset);
107 Material material = Prefs.getDefaultComponentMaterial(null, Material.Type.BULK);
108 nosecone.setMaterial(material);
109 bodytube.setMaterial(material);
110 finset.setMaterial(material);
112 String id = rocket.newMotorConfigurationID();
113 bodytube.setMotorMount(true);
115 for (Motor m: Databases.MOTOR) {
116 if (m.getDesignation().equals("B4")) {
117 bodytube.setMotor(id, m);
121 bodytube.setMotorOverhang(0.005);
122 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
124 rocket.getDefaultConfiguration().setAllStages();
131 public static Rocket makeBigBlue() {
136 FreeformFinSet finset;
139 rocket = new Rocket();
141 stage.setName("Stage1");
143 nosecone = new NoseCone(Transition.Shape.ELLIPSOID,0.105,0.033);
144 nosecone.setThickness(0.001);
145 bodytube = new BodyTube(0.69,0.033,0.001);
147 finset = new FreeformFinSet();
149 finset.setPoints(new Coordinate[] {
150 new Coordinate(0, 0),
151 new Coordinate(0.115, 0.072),
152 new Coordinate(0.255, 0.072),
153 new Coordinate(0.255, 0.037),
154 new Coordinate(0.150, 0)
156 } catch (IllegalFinPointException e) {
159 finset.setThickness(0.003);
160 finset.setFinCount(4);
162 finset.setCantAngle(0*Math.PI/180);
163 System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
165 mcomp = new MassComponent(0.2,0.03,0.045 + 0.060);
166 mcomp.setRelativePosition(Position.TOP);
167 mcomp.setPositionValue(0);
169 // Stage construction
170 rocket.addChild(stage);
171 rocket.setPerfectFinish(false);
174 // Component construction
175 stage.addChild(nosecone);
176 stage.addChild(bodytube);
178 bodytube.addChild(finset);
180 bodytube.addChild(mcomp);
182 // Material material = new Material("Test material", 500);
183 // nosecone.setMaterial(material);
184 // bodytube.setMaterial(material);
185 // finset.setMaterial(material);
187 String id = rocket.newMotorConfigurationID();
188 bodytube.setMotorMount(true);
190 for (Motor m: Databases.MOTOR) {
191 if (m.getDesignation().equals("F12J")) {
192 bodytube.setMotor(id, m);
196 bodytube.setMotorOverhang(0.005);
197 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
199 rocket.getDefaultConfiguration().setAllStages();
207 public static Rocket makeIsoHaisu() {
211 BodyTube tube1, tube2, tube3;
212 TrapezoidFinSet finset;
213 TrapezoidFinSet auxfinset;
216 final double R = 0.07;
218 rocket = new Rocket();
220 stage.setName("Stage1");
222 nosecone = new NoseCone(Transition.Shape.OGIVE,0.53,R);
223 nosecone.setThickness(0.005);
224 nosecone.setMassOverridden(true);
225 nosecone.setOverrideMass(0.588);
226 stage.addChild(nosecone);
228 tube1 = new BodyTube(0.505,R,0.005);
229 tube1.setMassOverridden(true);
230 tube1.setOverrideMass(0.366);
231 stage.addChild(tube1);
233 tube2 = new BodyTube(0.605,R,0.005);
234 tube2.setMassOverridden(true);
235 tube2.setOverrideMass(0.427);
236 stage.addChild(tube2);
238 tube3 = new BodyTube(1.065,R,0.005);
239 tube3.setMassOverridden(true);
240 tube3.setOverrideMass(0.730);
241 stage.addChild(tube3);
244 LaunchLug lug = new LaunchLug();
247 TubeCoupler coupler = new TubeCoupler();
248 coupler.setOuterRadiusAutomatic(true);
249 coupler.setThickness(0.005);
250 coupler.setLength(0.28);
251 coupler.setMassOverridden(true);
252 coupler.setOverrideMass(0.360);
253 coupler.setRelativePosition(Position.BOTTOM);
254 coupler.setPositionValue(-0.14);
255 tube1.addChild(coupler);
259 MassComponent mass = new MassComponent(0.05, 0.05, 0.280);
260 mass.setRelativePosition(Position.TOP);
261 mass.setPositionValue(0.2);
262 tube1.addChild(mass);
265 mass = new MassComponent(0.05, 0.05, 0.125);
266 mass.setRelativePosition(Position.TOP);
267 mass.setPositionValue(0.2);
268 tube1.addChild(mass);
271 mass = new MassComponent(0.40, R, 1.500);
272 mass.setRelativePosition(Position.TOP);
273 mass.setPositionValue(0.25);
274 tube1.addChild(mass);
277 auxfinset = new TrapezoidFinSet();
278 auxfinset.setName("CONTROL");
279 auxfinset.setFinCount(2);
280 auxfinset.setRootChord(0.05);
281 auxfinset.setTipChord(0.05);
282 auxfinset.setHeight(0.10);
283 auxfinset.setSweep(0);
284 auxfinset.setThickness(0.008);
285 auxfinset.setCrossSection(CrossSection.AIRFOIL);
286 auxfinset.setRelativePosition(Position.TOP);
287 auxfinset.setPositionValue(0.28);
288 auxfinset.setBaseRotation(Math.PI/2);
289 tube1.addChild(auxfinset);
294 coupler = new TubeCoupler();
295 coupler.setOuterRadiusAutomatic(true);
296 coupler.setLength(0.28);
297 coupler.setRelativePosition(Position.TOP);
298 coupler.setPositionValue(0.47);
299 coupler.setMassOverridden(true);
300 coupler.setOverrideMass(0.360);
301 tube2.addChild(coupler);
306 mass = new MassComponent(0.1, 0.05, 0.028);
307 mass.setRelativePosition(Position.TOP);
308 mass.setPositionValue(0.14);
309 tube2.addChild(mass);
311 Bulkhead bulk = new Bulkhead();
312 bulk.setOuterRadiusAutomatic(true);
313 bulk.setMassOverridden(true);
314 bulk.setOverrideMass(0.050);
315 bulk.setRelativePosition(Position.TOP);
316 bulk.setPositionValue(0.27);
317 tube2.addChild(bulk);
320 mass = new MassComponent(0.1, 0.05, 0.125);
321 mass.setRelativePosition(Position.TOP);
322 mass.setPositionValue(0.19);
323 tube2.addChild(mass);
327 InnerTube inner = new InnerTube();
328 inner.setOuterRadius(0.08/2);
329 inner.setInnerRadius(0.0762/2);
330 inner.setLength(0.86);
331 inner.setMassOverridden(true);
332 inner.setOverrideMass(0.388);
333 tube3.addChild(inner);
336 CenteringRing center = new CenteringRing();
337 center.setInnerRadiusAutomatic(true);
338 center.setOuterRadiusAutomatic(true);
339 center.setLength(0.005);
340 center.setMassOverridden(true);
341 center.setOverrideMass(0.038);
342 center.setRelativePosition(Position.BOTTOM);
343 center.setPositionValue(0);
344 tube3.addChild(center);
347 center = new CenteringRing();
348 center.setInnerRadiusAutomatic(true);
349 center.setOuterRadiusAutomatic(true);
350 center.setLength(0.005);
351 center.setMassOverridden(true);
352 center.setOverrideMass(0.038);
353 center.setRelativePosition(Position.TOP);
354 center.setPositionValue(0.28);
355 tube3.addChild(center);
358 center = new CenteringRing();
359 center.setInnerRadiusAutomatic(true);
360 center.setOuterRadiusAutomatic(true);
361 center.setLength(0.005);
362 center.setMassOverridden(true);
363 center.setOverrideMass(0.038);
364 center.setRelativePosition(Position.TOP);
365 center.setPositionValue(0.83);
366 tube3.addChild(center);
372 finset = new TrapezoidFinSet();
373 finset.setRootChord(0.495);
374 finset.setTipChord(0.1);
375 finset.setHeight(0.185);
376 finset.setThickness(0.005);
377 finset.setSweep(0.3);
378 finset.setRelativePosition(Position.BOTTOM);
379 finset.setPositionValue(-0.03);
380 finset.setBaseRotation(Math.PI/2);
381 tube3.addChild(finset);
384 finset.setCantAngle(0*Math.PI/180);
385 System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
388 // Stage construction
389 rocket.addChild(stage);
390 rocket.setPerfectFinish(false);
394 String id = rocket.newMotorConfigurationID();
395 tube3.setMotorMount(true);
397 for (Motor m: Databases.MOTOR) {
398 if (m.getDesignation().equals("L540")) {
399 tube3.setMotor(id, m);
403 tube3.setMotorOverhang(0.02);
404 rocket.getDefaultConfiguration().setMotorConfigurationID(id);
406 // tube3.setIgnitionEvent(MotorMount.IgnitionEvent.NEVER);
408 rocket.getDefaultConfiguration().setAllStages();