--- /dev/null
+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