[feat] Implements BoxBounded interface on several RocketComponents
This commit is contained in:
parent
709ded2659
commit
81b2f60e55
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -25,7 +26,7 @@ import net.sf.openrocket.util.MathUtil;
|
||||
*
|
||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||
*/
|
||||
public class InnerTube extends ThicknessRingComponent implements AxialPositionable, Clusterable, RadialParent, MotorMount {
|
||||
public class InnerTube extends ThicknessRingComponent implements AxialPositionable, BoxBounded, Clusterable, RadialParent, MotorMount {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
private static final Logger log = LoggerFactory.getLogger(InnerTube.class);
|
||||
|
||||
@ -135,6 +136,18 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab
|
||||
}
|
||||
}
|
||||
|
||||
public BoundingBox getInstanceBoundingBox(){
|
||||
BoundingBox instanceBounds = new BoundingBox();
|
||||
|
||||
instanceBounds.update(new Coordinate(this.getLength(), 0,0));
|
||||
|
||||
final double r = getOuterRadius();
|
||||
instanceBounds.update(new Coordinate(0,r,r));
|
||||
instanceBounds.update(new Coordinate(0,-r,-r));
|
||||
|
||||
return instanceBounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstanceCount() {
|
||||
return cluster.getClusterCount();
|
||||
|
@ -8,12 +8,13 @@ import net.sf.openrocket.preset.ComponentPreset;
|
||||
import net.sf.openrocket.preset.ComponentPreset.Type;
|
||||
import net.sf.openrocket.rocketcomponent.position.*;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
|
||||
|
||||
public class LaunchLug extends ExternalComponent implements AnglePositionable, Coaxial, LineInstanceable {
|
||||
public class LaunchLug extends ExternalComponent implements AnglePositionable, BoxBounded, Coaxial, LineInstanceable {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
@ -253,6 +254,19 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, C
|
||||
return this.instanceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getInstanceBoundingBox() {
|
||||
BoundingBox instanceBounds = new BoundingBox();
|
||||
|
||||
instanceBounds.update(new Coordinate(this.getLength(), 0,0));
|
||||
|
||||
final double r = getOuterRadius();
|
||||
instanceBounds.update(new Coordinate(0,r,r));
|
||||
instanceBounds.update(new Coordinate(0,-r,-r));
|
||||
|
||||
return instanceBounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-Line");
|
||||
@ -281,5 +295,4 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, C
|
||||
public void setAngleMethod(AngleMethod newMethod) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import net.sf.openrocket.rocketcomponent.position.AnglePositionable;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialPositionable;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
@ -22,7 +23,7 @@ import net.sf.openrocket.util.MathUtil;
|
||||
* @author widget (Daniel Williams)
|
||||
*
|
||||
*/
|
||||
public class RailButton extends ExternalComponent implements AnglePositionable, AxialPositionable, LineInstanceable {
|
||||
public class RailButton extends ExternalComponent implements AnglePositionable, AxialPositionable, BoxBounded, LineInstanceable {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
@ -210,6 +211,18 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
|
||||
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
|
||||
}
|
||||
|
||||
public BoundingBox getInstanceBoundingBox(){
|
||||
BoundingBox instanceBounds = new BoundingBox();
|
||||
|
||||
instanceBounds.update(new Coordinate(0, this.getTotalHeight(), 0));
|
||||
|
||||
final double r = this.getOuterDiameter();
|
||||
instanceBounds.update(new Coordinate(r,r,0));
|
||||
instanceBounds.update(new Coordinate(-r,-r,0));
|
||||
|
||||
return instanceBounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate[] getInstanceOffsets(){
|
||||
Coordinate[] toReturn = new Coordinate[this.getInstanceCount()];
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.util.BoundingBox;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
@ -16,7 +17,7 @@ import net.sf.openrocket.util.MathUtil;
|
||||
*
|
||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||
*/
|
||||
public abstract class RingComponent extends StructuralComponent implements Coaxial {
|
||||
public abstract class RingComponent extends StructuralComponent implements BoxBounded, Coaxial {
|
||||
|
||||
protected boolean outerRadiusAutomatic = false;
|
||||
protected boolean innerRadiusAutomatic = false;
|
||||
@ -111,8 +112,17 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||
}
|
||||
|
||||
public BoundingBox getInstanceBoundingBox(){
|
||||
BoundingBox instanceBounds = new BoundingBox();
|
||||
|
||||
instanceBounds.update(new Coordinate(this.getLength(), 0,0));
|
||||
|
||||
final double r = getOuterRadius();
|
||||
instanceBounds.update(new Coordinate(0,r,r));
|
||||
instanceBounds.update(new Coordinate(0,-r,-r));
|
||||
|
||||
return instanceBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the radial position of the component. The position is the distance
|
||||
|
Loading…
x
Reference in New Issue
Block a user