DGP - merged printing support from branch
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / LaunchLug.java
index 2670bc6063741d925b82dbd47926bb3b4df69d4d..500e9063bd34b31675b3ba88197b29e7dd40ae5f 100644 (file)
@@ -7,6 +7,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 
 
+
 public class LaunchLug extends ExternalComponent implements Coaxial {
 
        private double radius;
@@ -18,10 +19,10 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
        private double shiftY, shiftZ;
        
        
-       
+
        public LaunchLug() {
                super(Position.MIDDLE);
-               radius = 0.01/2;
+               radius = 0.01 / 2;
                thickness = 0.001;
                length = 0.03;
        }
@@ -30,7 +31,7 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
        public double getOuterRadius () {
                return radius;
        }
-
+       
        public void setOuterRadius (double radius) {
                if (MathUtil.equals(this.radius, radius))
                        return;
@@ -38,15 +39,15 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                this.thickness = Math.min(this.thickness, this.radius);
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
+       
        public double getInnerRadius() {
-               return radius-thickness;
+               return radius - thickness;
        }
-
+       
        public void setInnerRadius(double innerRadius) {
                setOuterRadius(innerRadius + thickness);
        }
-
+       
        public double getThickness() {
                return thickness;
        }
@@ -57,12 +58,12 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                this.thickness = MathUtil.clamp(thickness, 0, radius);
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
+       
        
        public double getRadialDirection() {
                return radialDirection;
        }
-
+       
        public void setRadialDirection(double direction) {
                direction = MathUtil.reduce180(direction);
                if (MathUtil.equals(this.radialDirection, direction))
@@ -70,9 +71,9 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                this.radialDirection = direction;
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
-
        
+       
+
        public void setLength(double length) {
                if (MathUtil.equals(this.length, length))
                        return;
@@ -81,7 +82,6 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
        }
        
        
-       
 
 
 
@@ -90,21 +90,21 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                super.setRelativePosition(position);
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
+       
        
        @Override
        public void setPositionValue(double value) {
                super.setPositionValue(value);
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
        
        
+
        @Override
        public Coordinate[] shiftCoordinates(Coordinate[] array) {
                array = super.shiftCoordinates(array);
                
-               for (int i=0; i < array.length; i++) {
+               for (int i = 0; i < array.length; i++) {
                        array[i] = array[i].add(0, shiftY, shiftZ);
                }
                
@@ -122,38 +122,38 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                 */
                RocketComponent body;
                double parentRadius;
-
+               
                for (body = this.getParent(); body != null; body = body.getParent()) {
                        if (body instanceof SymmetricComponent)
                                break;
                }
-
+               
                if (body == null) {
                        parentRadius = 0;
                } else {
-                       SymmetricComponent s = (SymmetricComponent)body;
+                       SymmetricComponent s = (SymmetricComponent) body;
                        double x1, x2;
                        x1 = this.toRelative(Coordinate.NUL, body)[0].x;
-                       x2 = this.toRelative(new Coordinate(length,0,0), body)[0].x;
+                       x2 = this.toRelative(new Coordinate(length, 0, 0), body)[0].x;
                        x1 = MathUtil.clamp(x1, 0, body.getLength());
                        x2 = MathUtil.clamp(x2, 0, body.getLength());
                        parentRadius = Math.max(s.getRadius(x1), s.getRadius(x2));
                }
-
+               
                shiftY = Math.cos(radialDirection) * (parentRadius + radius);
                shiftZ = Math.sin(radialDirection) * (parentRadius + radius);
-
-//             System.out.println("Computed shift: y="+shiftY+" z="+shiftZ);
-}
-
+               
+               //              System.out.println("Computed shift: y="+shiftY+" z="+shiftZ);
+       }
        
        
 
+
        @Override
        public double getComponentVolume() {
-               return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius-thickness));
+               return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius - thickness));
        }
-
+       
        @Override
        public Collection<Coordinate> getComponentBounds() {
                ArrayList<Coordinate> set = new ArrayList<Coordinate>();
@@ -161,37 +161,41 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
                addBound(set, length, radius);
                return set;
        }
-
+       
        @Override
        public Coordinate getComponentCG() {
-               return new Coordinate(length/2, 0, 0, getComponentMass());
+               return new Coordinate(length / 2, 0, 0, getComponentMass());
        }
-
+       
        @Override
        public String getComponentName() {
                return "Launch lug";
        }
-
+       
        @Override
        public double getLongitudalUnitInertia() {
                // 1/12 * (3 * (r1^2 + r2^2) + h^2)
                return (3 * (MathUtil.pow2(getInnerRadius())) + MathUtil.pow2(getOuterRadius()) +
                                MathUtil.pow2(getLength())) / 12;
        }
-
+       
        @Override
        public double getRotationalUnitInertia() {
                // 1/2 * (r1^2 + r2^2)
                return (MathUtil.pow2(getInnerRadius()) + MathUtil.pow2(getOuterRadius()))/2;
        }
-
-
+       
+       @Override
+       public boolean allowsChildren() {
+               return false;
+       }
+       
        @Override
        public boolean isCompatible(Class<? extends RocketComponent> type) {
                // Allow nothing to be attached to a LaunchLug
                return false;
        }
-
+       
     /**
      * Accept a visitor to this LaunchLug in the component hierarchy.
      *