]> git.gag.com Git - debian/openrocket/commitdiff
Added class with couple of helper methods to compute information about a rocket....
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 8 Jan 2012 00:47:37 +0000 (00:47 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 8 Jan 2012 00:47:37 +0000 (00:47 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@277 180e2498-e6e9-4542-8430-84ac67f01cd8

src/net/sf/openrocket/rocketcomponent/RocketUtils.java [new file with mode: 0644]

diff --git a/src/net/sf/openrocket/rocketcomponent/RocketUtils.java b/src/net/sf/openrocket/rocketcomponent/RocketUtils.java
new file mode 100644 (file)
index 0000000..2e4b63b
--- /dev/null
@@ -0,0 +1,34 @@
+package net.sf.openrocket.rocketcomponent;\r
+\r
+import java.util.Collection;\r
+\r
+import net.sf.openrocket.masscalc.BasicMassCalculator;\r
+import net.sf.openrocket.masscalc.MassCalculator;\r
+import net.sf.openrocket.masscalc.MassCalculator.MassCalcType;\r
+import net.sf.openrocket.util.Coordinate;\r
+\r
+public abstract class RocketUtils {\r
+\r
+       public static double getLength(Rocket rocket) {\r
+               double length = 0;\r
+               Collection<Coordinate> bounds = rocket.getDefaultConfiguration().getBounds();\r
+               if (!bounds.isEmpty()) {\r
+                       double minX = Double.POSITIVE_INFINITY, maxX = Double.NEGATIVE_INFINITY;\r
+                       for (Coordinate c : bounds) {\r
+                               if (c.x < minX)\r
+                                       minX = c.x;\r
+                               if (c.x > maxX)\r
+                                       maxX = c.x;\r
+                       }\r
+                       length = maxX - minX;\r
+               }\r
+               return length;\r
+       }\r
+\r
+       public static Coordinate getCG(Rocket rocket) {\r
+               MassCalculator massCalculator = new BasicMassCalculator();\r
+               Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), MassCalcType.LAUNCH_MASS);\r
+               return cg;\r
+       }\r
+       \r
+}\r