Added OutsideComponent.java; Implemented in ExternalComponent and Stage

OutsideComponent.java is an interface which describes components place outside the rocket (i.e. wing-tip pods, or strap-on boosters stages.

The interface is minimal, consisting merely of a couple getters and setters for the external position, rotation, and a flag to turn this on and off.
This commit is contained in:
Daniel_M_Williams 2015-06-03 10:41:01 -04:00
parent 7b6367b30b
commit 58d9e8f682
3 changed files with 190 additions and 36 deletions

View File

@ -16,7 +16,12 @@ import net.sf.openrocket.unit.UnitGroup;
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
public abstract class ExternalComponent extends RocketComponent {
public abstract class ExternalComponent extends RocketComponent implements OutsideComponent {
private boolean axial = true;
private double position_angular_rad = 0;
private double position_radial_m = 0;
private double rotation_rad = 0;
public enum Finish {
//// Rough
@ -127,6 +132,47 @@ public abstract class ExternalComponent extends RocketComponent {
}
@Override
public boolean isInline() {
return this.axial;
}
@Override
public void setInline(final boolean inline) {
this.axial = inline;
}
@Override
public double getAngularPosition() {
return this.position_angular_rad;
}
@Override
public void setAngularPosition(final double phi) {
this.position_angular_rad = phi;
}
@Override
public double getRadialPosition() {
return this.position_radial_m;
}
@Override
public void setRadialPosition(final double radius) {
this.position_radial_m = radius;
}
@Override
public double getRotation() {
return this.rotation_rad;
}
@Override
public void setRotation(final double rotation) {
this.rotation_rad = rotation;
}
@Override
protected void loadFromPreset(ComponentPreset preset) {
super.loadFromPreset(preset);

View File

@ -0,0 +1,64 @@
package net.sf.openrocket.rocketcomponent;
public interface OutsideComponent {
/**
* Indicates whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.)
*
* @return <code> True </code> This component is aligned with its parent
* <code> False </code> This component is offset from its parent -- like an external pod, or strap-on stage
*/
public boolean isInline();
/**
* Change whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.)
*
* @param inline True indicates that this component axially aligned with its parent. False indicates an off-center component.
*/
public void setInline(final boolean inline);
/**
* Get the position of this component in polar coordinates
*
* @return Angular position in radians.
*/
public double getAngularPosition();
/**
* Set the position of this component in polar coordinates
*
* @param phi Angular position in radians
*/
public void setAngularPosition(final double phi);
/**
* Get the position of this component in polar coordinates
*
* @return Radial position in radians (m)
*/
public double getRadialPosition();
/**
* Get the position of this component in polar coordinates
*
* @param radius Radial distance in standard units. (m)
*/
public void setRadialPosition(final double radius);
/**
* If component is not symmetric, this is the axial rotation angle (around it's own center). Defaults to 0.
*
* @return Rotation angle in radians.
*/
public double getRotation();
/**
* If component is not symmetric, this is the axial rotation angle (around it's own center). Defaults to 0.
*
* @param rotation Rotation angle in radians.
*/
public void setRotation(final double rotation);
}

View File

@ -3,12 +3,16 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
public class Stage extends ComponentAssembly implements FlightConfigurableComponent {
public class Stage extends ComponentAssembly implements FlightConfigurableComponent, OutsideComponent {
static final Translator trans = Application.getTranslator();
private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations;
private boolean axial = true;
private double position_angular_rad = 0;
private double position_radial_m = 0;
private double rotation_rad = 0;
public Stage() {
this.separationConfigurations = new FlightConfigurationImpl<StageSeparationConfiguration>(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration());
@ -61,4 +65,44 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
return copy;
}
@Override
public boolean isInline() {
return this.axial;
}
@Override
public void setInline(final boolean inline) {
this.axial = inline;
}
@Override
public double getAngularPosition() {
return this.position_angular_rad;
}
@Override
public void setAngularPosition(final double phi) {
this.position_angular_rad = phi;
}
@Override
public double getRadialPosition() {
return this.position_radial_m;
}
@Override
public void setRadialPosition(final double radius) {
this.position_radial_m = radius;
}
@Override
public double getRotation() {
return this.rotation_rad;
}
@Override
public void setRotation(final double rotation) {
this.rotation_rad = rotation;
}
}