1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.util.Coordinate;
6 public class CenteringRing extends RadiusRingComponent {
8 public CenteringRing() {
9 setOuterRadiusAutomatic(true);
10 setInnerRadiusAutomatic(true);
16 public double getInnerRadius() {
17 // Implement sibling inner radius automation
18 if (isInnerRadiusAutomatic()) {
20 // Component can be parentless if disattached from rocket
21 if (this.getParent() != null) {
22 for (RocketComponent sibling: this.getParent().getChildren()) {
24 * Only InnerTubes are considered when determining the automatic
25 * inner radius (for now).
27 if (!(sibling instanceof InnerTube)) // Excludes itself
30 double pos1 = this.toRelative(Coordinate.NUL, sibling)[0].x;
31 double pos2 = this.toRelative(new Coordinate(getLength()), sibling)[0].x;
32 if (pos2 < 0 || pos1 > sibling.getLength())
35 innerRadius = Math.max(innerRadius, ((InnerTube)sibling).getOuterRadius());
37 innerRadius = Math.min(innerRadius, getOuterRadius());
41 return super.getInnerRadius();
46 public void setOuterRadiusAutomatic(boolean auto) {
47 super.setOuterRadiusAutomatic(auto);
51 public void setInnerRadiusAutomatic(boolean auto) {
52 super.setInnerRadiusAutomatic(auto);
56 public String getComponentName() {
57 return "Centering ring";
61 public boolean isCompatible(Class<? extends RocketComponent> type) {